"View State Invalid" Error While Submitting Form thru JavaScript

V

Vinod I

Hi Team,

When I tryed following code, I am getting the Runtime Error as
"The View State is invalid for this page and might be corrupted."
Exception Details: System.Web.HttpException: The View State is invalid for
this page and might be corrupted.
Stack Trace:
[HttpException (0x80004005): The View State is invalid for this page and
might be corrupted.]
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +150
System.Web.UI.Page.LoadPageViewState() +16
System.Web.UI.Page.ProcessRequestMain() +421



And My Code is in ".js" file:
function save()

{

document.forms(0).method = "post";

document.forms(0).action = "formsave1.aspx";

document.forms(0).submit();

}

Please let me know wat can be the reason.

Thanks in advance..

cheers !!
 
M

matt

If you change the action attribute of the form then the Viewstate will
become invalid, you will be posting back data to a different place. The
idea with a webform is that it is always posted back to itself, viewstate is
loaded so your page knows when to run onchange, onclick.. etc server side
events. If you postback to a different page then there would be no way of
knowing if the controls would be the same (and if they were what would be
the point of having a separate webform anyway).

Hope that helps you solves your problem, the only time I can think of that
you would want to overwrite the action attribute using Javascript is if you
have made a previous call to Context.Rewritepath in an HttpModule. You
could then use Javascript to correct the incorrect action attribute that is
output by ASP.net, which causes exactly the same error you are seeing.

Matt
http://www.3internet.com
Inigo Content Management - c# asp.net cms
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,187
Latest member
RosaDemko

Latest Threads

Top