Page.IsValid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    Page.IsValid

    I have a form with a Serial No and Pin text box which are validated with
    required field validators. Once they are validated my code goes to a
    btn_Click event and if Page.IsValid then checks to see if the Serial No
    and Pin is in a database table.

    My problem is that once the user has entered details in the Serial No
    and Pin boxes making Page.IsValid true, when I clear these text boxes
    Page.IsVaild still seems to be true, because my Page.IsValid code still
    executes and tells the user that their Serial No/Pin does not exist, as
    well as telling the user that they need to enter stuff in the text
    boxes. This is my code :

    public void btnSubmit_Click (object sender, EventArgs e)
    {
    feedbackLabel.T ext = "";

    if (Page.IsValid)
    {
    string strSerialNumber , strPinNumber, strSQL;

    strSerialNumber = SerialNumber.Te xt.Trim();
    strPinNumber = PinNumber.Text. Trim();
    strSQL = "SELECT * FROM purple_cards WHERE serial = '" +
    strSerialNumber + "' AND PIN = '" + strPinNumber + "'";

    SqlConnection objConnection = new
    SqlConnection(C onfigurationSet tings.AppSettin gs["strConnect "]);
    SqlDataReader objDataReader = null;
    SqlCommand objCommand = new SqlCommand(strS QL,
    objConnection);

    try
    {
    objConnection.O pen();
    objDataReader = objCommand.Exec uteReader();

    if (objDataReader. Read() == true)
    {
    feedbackLabel.T ext = "Record found";
    }
    else
    {
    feedbackLabel.T ext = "Record not found";
    }
    }
    catch
    {
    feedbackLabel.T ext = "Connection failed to open
    successfully";
    }
    }
    }

    Has anybody else had this problem?


    Any help would be really appreciated.


    Mike



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
Working...