Wrox Programmer Forums
|
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 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 December 17th, 2004, 06:58 PM
Authorized User
 
Join Date: Aug 2004
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to macupryk Send a message via Yahoo to macupryk
Default cross-page posting

I have the following two pages. I am wondering how can I return back.
When I click on the back link to go to page one I want the values to be saved or in the textboxes. What is the appropriate way in visual studio 2005?

CrossPage1.aspx
===============
<%@ Page Language="C#" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
        <table>
            <tr>
                <td>Enter some Text:</td>
                <td><asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td>Enter more Text:</td>
                <td><asp:TextBox ID="TextBox2" Runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <asp:LinkButton ID="LinkButton1" Runat="server" PostBackUrl="CrossPage2.aspx">Submit Page</asp:LinkButton>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

CrossPage2.aspx
===============
<%@ Page Language="C#" %>
<%@ PreviousPageType VirtualPath="CrossPage1.aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">
    void Page_Load(object sender, System.EventArgs e)
    {
        // If posted from CrossPage1.aspx to CrossPage2.aspx...

        if (PreviousPage == null)
        {
            Response.Write("Invoke me only through cross-page posting.");
             Response.End();
             return;
        }
        else
        {
            // Retrieve the textbox values from FindControl
            TextBox TextBox1;
            TextBox TextBox2;
            TextBox1 = (TextBox)PreviousPage.FindControl("TextBox1");
            TextBox2 = (TextBox)PreviousPage.FindControl("TextBox2");
            Response.Write(TextBox1.Text+"<br>"+TextBox2.Text+ "<br>");
         }


    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Page2</title>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
        <asp:Label ID="Label1" Runat="server" EnableViewState="False"></asp:Label>&nbsp;<br />
        <br />
        <asp:HyperLink ID="HyperLink1" Runat="server" NavigateUrl="crosspage1.aspx">Back</asp:HyperLink>
    </div>
    </form>
</body>
</html>




Knowledge is to be shared.
__________________
Knowledge is to be shared.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross-Page Posting roman BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 1 June 25th, 2008 10:25 AM
cross-page posting within pages with master file.. poogles ASP.NET 2.0 Basics 2 August 6th, 2007 05:11 AM
Posting String Array From one page to another page Samatha ASP.NET 1.0 and 1.1 Professional 1 December 6th, 2006 03:54 AM
Page is posting to itself parypoo ASP.NET 1.0 and 1.1 Professional 2 April 17th, 2006 06:08 AM
Page Not Posting RGB ASP.NET 1.0 and 1.1 Basics 11 March 7th, 2006 01:58 PM





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