I am working with Visual Web Developer 2008 Express and C# in the code behind. Te problem I am having is in the validation part of the program. When an user enters a number in the provided textbox and then hits the corresponding button to update the web pages labels I get this error.
Quote:
Server Error in '/' Application
--------------------------------------------------------------------------------
Unable to validate data.
Description: HTTP 500. Error processing request.
Stack Trace:
System.Web.HttpException: Unable to validate data.
at System.Web.UI.ObjectStateFormatter.ValidateInput (System.Security.Cryptography.HashAlgorithm algo, System.Byte[] data, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
at System.Web.UI.ObjectStateFormatter.Deserialize (System.String inputString) [0x00000] in <filename unknown>:0
at System.Web.UI.ClientScriptManager.RestoreEventVali dationState (System.String fieldValue) [0x00000] in <filename unknown>:0
at System.Web.UI.Page.RestorePageState () [0x00000] in <filename unknown>:0
at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0
at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
--------------------------------------------------------------------------------
Version information: Mono Runtime Version: 2.6.7 (tarball Mon Oct 18 20:36:47 EDT 2010); ASP.NET Version: 2.0.50727.1433
|
I have IsPostBack validation set up in the page load area of the C# code behind set up like this:
Code:
protected void Page_Load(object sender, EventArgs e)
{
//validation
if (IsPostBack)
{
Validate();
}
}
The page has 13 textboxes and 14 buttons. The textboxes are only accessed when a corresponding button for it is clicked. Here is one of the buttons code behind code:
Code:
protected void Btnsply_Click(object sender, ImageClickEventArgs e)
{
//check for proper entry in txtbox
currentString = TBSply.Text;
tester = CorrectEntry(currentString);
if (tester)
{
//convert string to integer
currentInt = Convert.ToInt32(currentString);
//clear the labels if amount <= 0
if (currentInt > 0)
{
//set the current stats
ResConverter(0);
//set the correct numbers to the gridview2 tables
GridSetter(0);
//update the correct label values for current troop type
Lblsply.Text = GridView2.Rows[0].Cells[1].Text;
Lblsplypop.Text = GridView2.Rows[0].Cells[2].Text;
Lblsplyfood.Text = GridView2.Rows[0].Cells[3].Text;
Lblsplywood.Text = GridView2.Rows[0].Cells[4].Text;
Lblsplyore.Text = GridView2.Rows[0].Cells[5].Text;
Lblsplystone.Text = GridView2.Rows[0].Cells[6].Text;
Lblsplyup.Text = GridView2.Rows[0].Cells[7].Text;
Lblsplydaily.Text = GridView2.Rows[0].Cells[8].Text;
}
else
{
//clear the current row and reset focus
ClearAllLabels(0);
TBSply.Text = "";
TBSply.Focus();
}
}
else
{
//reset textbox entry
TBSply.Text = "";
TBSply.Focus();
}
}
The webpage works fine in the intranet web browser during debugging. It is only when I publish and then upload the files to the internet webpage that I get this error. Do I have to set up validation for each and every one, or is this the proper way to use validation?
