Hi,
I am currently studying the book (Beginning ASP.NET using
VB.NET: ISBN: 1861005040 (Published Year: 2001)).
I am stuck at the code
pass from
Page1.aspx to
Page2.aspx, I think it could be todo with the ASP.NET Version. I am using
Microsoft.NET Framework v1.1.4322.
I have try putting the runat="server" in the Form section, to get rid of the error, but the submit does not Work.
I know how to extract the data from the same page, but since I am start to learn ASP.NET that's why I want to know why this method of passing from page1 to page2 doesn't work.
Please see the following code.
Thanks in advance.
Regards Dat.
Code:
Page1.aspx
-------------------------------------------------
Code:
<html>
<head>
<title>Datagrid Control example</title>
</head>
<body>
<form action="Page2.aspx" method="post" <s>runat="server"</s>>
<p>
Enter Your Name:
<asp:TextBox id="TextBox1" runat="server" />
</p>
<p>
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</p>
</form>
</body>
</html>
Page2.aspx
-------------------------------------------------
Code:
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load()
Message1.text = Request.Form("TextBox1")
End Sub
</script>
<html>
<head>
<title>datacontrol response</title>
</head>
<body>
<p>
<asp:Label id="Message1" runat="server" />
</p>
</body>
</html>
Error When running
Page1.aspx
Server Error in '/5040' Application.
---------------------------------------------------------------------
Control 'TextBox1' of type 'TextBox' must be placed inside a form tag with runat=server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'TextBox1' of type 'TextBox' must be placed inside a form tag with runat=server.