Click to See Complete Forum and Search --> : Webform


vijaysri
July 29th, 2003, 03:46 PM
I am getting an error when I run the following example.When I include form runat="server in the HTML body section of the following code the server is displaying the Holiday Page,but when I click the submit button the server is producing an error.
"The viewstate is invalid for this page and might be corrupted. "
I need help

---------
holidaypage.aspx
-------------------

<html>
<head>
<title>Holiday Page</title>
</head>
<body>
<form action="holidayresponsepage.aspx" method="post">
<h1>Vijay Holidays</h1>
Please enter details here.
<br /><br />
Name:<asp:textbox id="FullName" runat="server" />
<br/><br/>
Address:<asp:textbox id="Address" rows=5 textmode="multiline" runat="server"/>
<br/><br/>
Sex-<asp:radiobuttonlist id="Sex" runat="server">
<asp:listitem value="Male"/>
<asp:listitem value="Female"/>
</asp:radiobuttonlist>
Please select the destination you would like details on:
<asp:dropdownlist id="Destination" runat="server">
<asp:listitem value="Madrid"/>
<asp:listitem value="Barcelona"/>
<asp:listitem value="Lisbon"/>
<asp:listitem value="Oslo"/>
<asp:listitem value="Prague"/>
</asp:dropdownlist>
<br/><br/>
<input type="submit">
<input type="Reset">
</form>
</body>
</html>

---------
holidayresponsepage.aspx Code
-------------------------------------
<script runat="server" language="vb">
sub page_Load()
response.write("<b>Name:</b> " + request.form("FullName") + "<br/>")
response.write("<b>Address:</b> " + request.form("Address") + "<br/>")
response.write("<b>Sex:</b> " + request.form("Sex") + "<br/>")
response.write("<b>Destination:</b> " + request.form("Destination") + "<br/>")
end sub
</script>
<html>
<head>
<title>Holiday Page</title>
</head>
<body>
<br/><br/>
These details have been entered into our database, you should receive a confirmation email from us shortly
<br/><br/>
</body>
</html>


[Sonu Kapoor: please use the code tag before entering some code]

coolbiz
July 29th, 2003, 06:26 PM
Your FORM tag requires RUNAT=server.

-Cool Bizs

vijaysri
July 29th, 2003, 07:17 PM
Hi Cool Bizs,

Thank you very much for the help. However, when I use the runat server form tag server is displaying the firstpage which is(holidaypage.aspx). but, when I click the submit button nothing is happening. The code should show the second page which is holidayresponsepage.aspx. The book says "the runat server attribute prohibits us from moving to another page as it automatically create an action attribute within the firstpage specified." Any idea????

vijaysri

coolbiz
July 29th, 2003, 10:45 PM
First of all, I'm also new to ASP.NET. There tons more stuff that I might not even know about it yet. But so far this is my understanding.

When you use the ASPX web controls, their information are tracked by the _VIEWSTATE variable (hidden input type). And this VIEWSTATE is specific for each page that is rendered. So when the first page rendered, the VIEWSTATE information is specific for that first page. Second page will not be able to use that information as it has no information about the VIEWSTATE of the first page.

I've never done as what you have right now. My code has always been posted back and processed by the same page. However, in your case, you should be able to DISABLE the VIEWSTATE information from the WEBFORM property. This property is called EnableViewState and set it to FALSE. Therefore, no VIEWSTATE information will be tracked and your second page should be able to process the form input.

The drawback is you are back using the old ways of processing the form input, Request.Form or Request.QueryString.

Again, this information is just based on my understanding of what I've programmed so far with ASPX. DO NOT quote anything from here :)

-Cool Bizs

vijaysri
August 1st, 2003, 09:22 PM
Hi Cool Bizs,

Thanks for the info. I changed my code and used only server controls. It is working. Here are some useful links related to the page navigation.

http://www.stardeveloper.com/articles/display.html?article=2003061901&page=1

http://aspnet101.com/aspnet101/tutorials.aspx?id=20

http://www.ondotnet.com/pub/a/dotnet/2003/04/07/aspnetnav.html

coolbiz
August 2nd, 2003, 12:01 AM
Good job. This is the cool thing about this forum. Instead of me providing you with the answer for your question, you actually provided me with answer for the question that I've had for a while.

Thanks,
-Cool Bizs