Well, it's a bad practice that what you're trying to achieve.
Instead, pass the control values as a parameters to the function of your class, which would return something.
For example,
Login.cs
public string LogIn(string user, string password)
{
string STATUS = string.empty;
string query = "select * from User where UserName = '" + user + "', AND Password = '" + password + "'";
SqlCommand cmd = new SqlCommand(query, con);
int n = cmd.ExecuteNonQuery();
STATUS = (n > 0 ? "Success !" : "Error");
return STATUS;
}
WebLogin.aspx.cs
{
Login l = new Login();
string status = l.LogIn(txtUserName.Text, txtPassword.Text);
Response.Write(stauts);
}
It is just the basic idea, how you can go about this. Hope this would help you.
-KR