Ask a Question related to ASP.NET General, Design and Development.
-
Mike P #1
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.Text = "";
if (Page.IsValid)
{
string strSerialNumber, strPinNumber, strSQL;
strSerialNumber = SerialNumber.Text.Trim();
strPinNumber = PinNumber.Text.Trim();
strSQL = "SELECT * FROM purple_cards WHERE serial = '" +
strSerialNumber + "' AND PIN = '" + strPinNumber + "'";
SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConnect"]);
SqlDataReader objDataReader = null;
SqlCommand objCommand = new SqlCommand(strSQL,
objConnection);
try
{
objConnection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
{
feedbackLabel.Text = "Record found";
}
else
{
feedbackLabel.Text = "Record not found";
}
}
catch
{
feedbackLabel.Text = "Connection failed to open
successfully";
}
}
}
Has anybody else had this problem?
Any help would be really appreciated.
Mike
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Mike P Guest
-
Splitting or separating 1 multi page pdfdocument into individual page documents
I am looking for any product that will take a multi page pdf file and burst or separate it into individual pdf files created from each page. Mac... -
Calling IsValid in a web control
Hi All Is there anyway to check the IsValid property in a user control? I've made a user control that holds a number of validators. There are... -
Accessing Values of local variables in previous page when using custom error page
Hello, I have created a nice funky 500 - 100 error page which gives a nicer error; happily loops through and supplies querysting information, all... -
Prevent 'Page has expired' when a client hits back to return to a search page
I have a search page that I want to enable private caching so that when a user hits the back button they dont get the page has expired error. I... -
Calling a html page from an asp page then returning to the next statement on the original asp page
Hi! I have an ASP page that calls excel to create a report. This works fine. Now I need to call a html calendar page to filter what rows are...



Reply With Quote

