hii i hav a problem with thsi code
check it once
if (!this.IsPostBack)
// Create a random code and store it in the Session object.
this.Session["CaptchaImageText"] = GenerateRandomCode();
else
{
// On a postback, check the user input.
if (this.CodeNumberTextBox.Text ==
this.Session["CaptchaImageText"].ToString())
{
// Display an informational message.
this.MessageLabel.CssClass = "info";
this.MessageLabel.Text = "Correct!";
}
else
{
//Display an error message.
this.MessageLabel.CssClass = "error";
this.MessageLabel.Text = "ERROR: Incorrect, try again.";
// Clear the input and create a new random code.
this.CodeNumberTextBox.Text = "";
this.Session["CaptchaImageText"] = GenerateRandomCode();
}
}
}
the second else is directly executing without anywrong entry of text
so please tell how to correct thsi code
Loading
Niradhip ChakrabortyPosted Aug 27, 2008, 8:48 AM
if
(!this.IsPostBack){
// Create a random code and store it in the Session object.Session["CaptchaImageText"] = GenerateRandomCode();
}
else{
// On a postback, check the user input. if (CodeNumberTextBox.Text == Session["CaptchaImageText"].ToString()){
// Display an informational message.MessageLabel.CssClass = "info";
MessageLabel.Text = "Correct!";
}
else{
//Display an error message.MessageLabel.CssClass = "error";
MessageLabel.Text = "ERROR: Incorrect, try again.";
// Clear the input and create a new random code.CodeNumberTextBox.Text = "";
Session["CaptchaImageText"] = GenerateRandomCode();
}
}