'WebForm_PostBackOptions' is undefined Error on ASP.Net website

3.3k Views Asked by At

My precompiled ASP.Net 4 website has just developed a JavaScript error on a button click event that is supposed to postback to another page.

I have never seen this error before and the site was working. What the heck have I done? I'm not even sure what code to show you???

The page works fine when debugging in VS2010.

I was hoping to launch the site today so any help would be greatly appreciated.

1

There are 1 best solutions below

0
On

I never actually found what was causing every button with a postback to generate the error. However I did find that an earlier version was working OK. So I reconsrtructed the site, page by page and the error went. Bar one!

This was on the order page and generated the same error (empty axd files etc). But this time I was able to track it down to this section of code:

 if (ViewState["billID"] == null)
 {
      billID = Convert.ToInt32(ViewState["billID"].ToString());
 }

Amending the code to...

if (ViewState["billID"] == null)
{
     billID = Convert.ToInt32(ViewState["billID"]);
}

...fixed it.

I was being a little over zealous with using ToString()! Hopefully this will help someone else with the same issue.