I'm working on a web form which works fine as long as it posts back to itself. In Reports.aspx I have:
<form runat="server" method="post">
but, when I try to get it to post to a different page:
<form runat="server" method="post" action="DisplayReport.aspx">
I get the "Validation of viewstate MAX failed" error. I've tried setting the machine key and disabling the viewstate in web.config, but nothing seems to help. Am I stuck posting back to the same page? If so what is the point of the action attribute?
You can submit to a different page, but you need to use the PostBackUrl
property of a button, not the form's action
attribute.
Instead of this:
<form runat="server" method="post" action="DisplayReport.aspx">
<!-- form stuff goes here -->
<asp:button runat="server" text="Submit" />
</form>
Do this:
<form runat="server">
<!-- form stuff goes here -->
<asp:button runat="server" text="Submit" postbackurl="DisplayReport.aspx" />
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With