I am working on a warning system for another person's website. The premise is simple enough, if the conditions are met and the warningFlag variable is set "", the warning is made and the warningFlag variable is set to "Y".
However it never retains the value and always triggers the warning. I have tried the ViewState and it would not work. Bit confused as to why it would not work as the ViewState should have done the trick. Maybe I am missing something? Can you help out an ASP beginner?
Page_Load
if (ViewState["warningFlag"] == null)
ViewState.Add("warningFlag", ""); //Add the flag
else
ViewState["warningFlag"] = ""; //Reset the flag
Button click event
if (ViewState["warningFlag"].ToString() == "")
{
if (this.checkForWarning()) //Checks if Warning conditions are met
{
ViewState["warningFlag"] = "Y";
//Warning Message Code goes here
return;
}
}