sorry, bub, but that makes no sense because:
1) how is Page.IsValid supposed to know if the user is in your database
2) if you do already know that the user is valid, what is the point of this function.
In any event, here is what you need to do to fix it. I will give you two ways. The first takes the least amount of changes to your code. However, I would recommend the second as I hate multiple return paths.
Fix 1:
privatebool Custvaluserid_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
SqlConnection conn= new SqlConnection();
conn.ConnectionString="server= 'server name';uid=sa;pwd=;database=";
string query="select ADMINUSERID from ADMIN where ADMINUSERID='admin'";
SqlCommand comm=new SqlCommand(query,conn);
conn.Open();
SqlDataReader dr=comm.ExecuteReader();
args.IsValid = false;
while(dr.Read())
{
bool msg;
string txtuserid;
txtuserid=(dr [ "ADMINUSERID" ].ToString ( ));
if(txtuserid==args.Value)
{
args.IsValid = true;
msg=true;
return msg;
}
}
return false;
}
Fix 2
privatebool Custvaluserid_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
SqlConnection conn= new SqlConnection();
conn.ConnectionString="server= 'server name';uid=sa;pwd=;database=";
string query="select ADMINUSERID from ADMIN where ADMINUSERID='admin'";
SqlCommand comm=new SqlCommand(query,conn);
conn.Open();
SqlDataReader dr=comm.ExecuteReader();
args.IsValid = false;
while(dr.Read())
{
if(dr[ "ADMINUSERID" ].ToString( )==args.Value)
{
args.IsValid = true;
break;
}
}
return args.IsValid;
}