Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2004, 08:16 PM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dati
Default Error Pass Form data from Page1.aspx to Page2.aspx

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.
 
Old January 27th, 2004, 01:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I don't have the book you are using, so I don't know specifically what it is trying to do. You may be able to change:

Code:
<asp:TextBox id="TextBox1" runat="server" />
into
Code:
<input type="Text" id="TextBox1"/>
You can do this because you are referencing the value of the textbox through the request.form() collection.

Or you can leave the <asp:TextBox>, change the form to include the "runat='server'", Change the submit button to include the "runat='server'" or change it to a web control, and use the Server.Transfer() method to redirect to the second page. Keep in mind that when you use Server.Transfer (make sure the second parameter is set to true; this preserves the previous form state) that the browser will still show "page1.aspx" in the address bar.

Lastly, keep in mind that .NET doesn't allow posting to another form. To do this in .NET, you can do it in several ways. You can store the values that are posted back in the Session, you can use javascript to redirect (I saw an article on the web), or you can use the Server.Transfer() or Server.Execute() methods.

Brian
 
Old January 28th, 2004, 02:27 AM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dati
Default

Thank your for your comments Brian,

I've posted in the following area as well and have found the answer I needed. (ie. the posting of the form from page1 to page2 is not supported) as you have mention it.

I have posted the solution using Server.Transfer here:
http://p2p.wrox.com/topic.asp?TOPIC_ID=9004

Thanks again.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass values from Aspx page to Flash Muthunagai.A ASP.NET 1.0 and 1.1 Basics 0 April 25th, 2007 11:41 PM
HowTo Pass Form data from Page1.aspx to Page2.aspx dati ASP.NET 1.0 and 1.1 Basics 6 January 27th, 2004 06:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.