Submit form

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

I have page search.asp. When I click button, I submit form with script:

form1.action="searchResults.aspx"
form1.submit

On page searchResults.aspx I get the following error message:

The viewstate is invalid for this page and might be corrupted.

Does anybody know why?

Thank you,
Simon
 
To pass the current submit to another page use Server.Transfer method, which
will submit the current page and will pass the request to another page
Is there any special reason to do it like your way ?

Reagrds,
Martin
 
simon said:
I have page search.asp. When I click button, I submit form with script:

form1.action="searchResults.aspx"
form1.submit

On page searchResults.aspx I get the following error message:

The viewstate is invalid for this page and might be corrupted.

Does anybody know why?

Thank you,
Simon

I guess it is because you submit (probably via POST) to an aspx:
that aspx then expects a "postback", so tries to read the viewstate,
which normally is sent via a hidden input.
That input is not present (or not valid), therefore you get this error.

There is a way around this: you can set the directive
<%@ Page EnableViewStateMac="false" %>
in your aspx file.

I noticed you are trying to post from an asp to an aspx. (or is that a typo?)
The "usual" way for asp.net is to have an aspx page post to itself.
(then you won't have those viewstate problems)

Hans Kesting
 
Back
Top