< <
There is one workaround for posting to another .aspx page. Omit the runat="server" attribute. What Runat attribute does is it will override the action attribute to the file name submitted. If you omit the runat attribute, action will take to another aspx page with the form values posted. But one disadvantage is there, we cant use server controls inside the first page. Those values cant be posted to another .aspx page. But one good thing is we can use HTML controls. Runat=server in HTML controls will allow us to access those values in the posted page.
Let us see one example, First.aspx
<head><title>First Page</title></head>
<body>
<form name="frmFirstPage" action="Second.aspx" method="post">
<input type="text" name="FirstName" id="FirstName" runat="server"/>
<input type="text" name="LastName" id="LastName" runat="server"/>
<input name="Submit" type="Submit" runat="server" ID="Submit1"/>
</form>
</body>
</html>
Second.aspx
<head><title>Second Page</title></head>
<body>
<form id="frmFirstPage" method="post" runat="server">
FirstName:<%=Response.Write(Request["FirstName"])%>
LastName:<%=Response.Write(Request["LastName"])%>
</form>
</body>
</html>
If u enter Naveena as FirstName and Maadhaven as second name in the First.aspx, you can see the output in second.aspx as
FirstName : Naveena
LastName : Maadhaven
This is the very simple example but this shows whatever we did using ASP is still available in ASP.NET. But you should go for this approach when you don't need any web server or rich controls in your application. Hope this article will be useful to you.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
kikiPosted Oct 2, 2007, 4:18 AM
I need to post data, which are placed in several tables, to another page. The problem is that the data is produced in First.aspx.cs file and I want 1) to send them to the Second.aspx.cs file, 2) to sort them 3) to show them at the Second.aspx file, in a specific position can you help me with that???