0

I have an ASP.NET Web Forms site and I am attempting to use a jQuery dialog to show values from a database for categories / names after a button click on the main page.

Running the page inside the jQuery Dialog directly in a browser works flawlessly, but running it inside the jQuery dialog causes this error on the first run.

Uncaught Error: Sys.WebForms.PageRequestManagerServerErrorException: The state information is invalid for this page and might be corrupted.

If I close the Dialog and open it again after this error, it works perfectly?! I have read all I can find on ViewState and UpdatePanel and none of the normally suggested solutions work for me. I suspect the issue is that my jQuery Dialog is loading a separate aspx page and this is being loaded on top of the main page. Because of this my View State is invalid for the main page, not the page in the jQuery Dialog, on postback.

The error occurs, on the first load, with any modification of the page, i.e set a label text, show / hide label, choose a TreeView Node, etc. Basically any event that would modify the appearance of the Page.

Also, I am loading the dialog page into a dialog div on the main page so the main page has those controls at that point...

r3dfarce
  • 161
  • 1
  • 2
  • 9

1 Answers1

0

Using the two links below I've resolved my problem. Instead of loading the aspx page directly into the jQuery Dialog, I am now loading the aspx page in an iframe and that is inside of my dialog div (see first link for an example).

jQuery UI Dialog using iframe URL

jQuery UI dialog is setting iframe width automatically

Some important points:

  • Loading an aspx page (directly) in a jQuery Dialog loads the page as pure HTML to the main page. Think of this as appending the aspx page to the main page.
  • Loading an aspx page in an iframe is akin to navigating directly to the page in a web browser.
  • The ViewState is inaccurate on POST with the Dialog appended because the main page now has a slew of previously non-existent controls added to it.
  • The ViewState is contained within the iframe for the page you are loading in the dialog in the second situation because it is effectively a separate page. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe

I hope someone finds this useful and doesn't suffer the weeks of researching this issue like I did, if you are an ASP.NET n00b as I was.

r3dfarce
  • 161
  • 1
  • 2
  • 9