Hi,
The code goes something like this:
protected bool IsOKToSend()
{
bool IsOK = true;
lblErrorSending.Visible = false;
if (txtUserName.Text == "" )
{
lblErrorSending.Text = "Please enter your username before sending.";
IsOK = false;
}
return IsOK;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (IsOKToSend())
{
adsUser.Insert();
Response.Redirect("complete.aspx");
}
else
{
lblErrorSending.Visible = true;
}
}
For some reason it doesn't work consistently on the live server. Keep in mind that it ALWAYS works on my local development machine and SOMETIMES (about 1 in 3 tries) works on the live machine. When it fails on the live server the page reloads and all viewstate are lost.
I have a default error catch in my webconfig file and the page is never redirected to the error page.
Consistent bug are easy to troubleshoot but something like this isn't.
Any idea on what could make this page sometime works and sometime not and/or why the viewstate aren't kept when it fails to work? Why am I not getting the same problem on my local machine?
I tried merging the two function to see if calling the external function was causing the issue but it didn't change anything unfortunately. Also, the value of IsOK does not seem to influence whether I'll get the bug or not.
I removed all the code in the page load function to make sure to troubleshoot correctly but I'm still getting the same issue.
Any idea will be appreciated.
Edit: I was gonna send this as is but I decided to try the following:
protected void btnSubmit_Click(object sender, EventArgs e)
{
bool IsOK = true;
lblErrorSending.Visible = false;
if (txtUserName.Text == "" )
{
lblErrorSending.Text = "Please enter your username before sending.";
IsOK = false;
}
lblErrorSending.Visible = !IsOK;
}
If I click a few times on the button the page does lose the viewstate value after a few tries but not always. So the main issue here appears to be a problem with the viewstate not working correctly all the time. Any idea?
Thanks.