Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cross Page Posting
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Cross Page Posting
Environment versions
Environment:
C# 3.0
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01454461
Message ID:
01454461
Views:
79
I am trying to do a "cross-page posting", where the values of the controls on the first page, which calls the second page, will be able to be displayed by label controls on the 2nd page. I keep getting a namespace error that says I "...cannot implicitly convert a textbox to string type". I am not sure what I need to do at this point.

I've got the following code on the 1st page which calls the 2nd page usign the postbackurl property:
(The two textboxes on the first page are called txtFirstName and txtLastName.)
<asp:Button ID="btnSubmit" runat="server" Text="Submit" PostBackUrl="~/ShowContactData.aspx" />
And the following code on the 2nd page (ShowContactData.aspx.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Program2
{
    public partial class ShowContactData : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (PreviousPage != null)
            {
                // Create an instance of the previous page's controls.
                TextBox firstName = null;
                TextBox lastName  = null;

                // Fill variables with the values in the previous page using FindControl() of PreviousPage.
                firstName = (TextBox)this.PreviousPage.FindControl("txtFirstName");
                lastName  = (TextBox)this.PreviousPage.FindControl("txtLastName");

                // Bind the labels using values in textboxes.
                lblFirstName.Text = firstName;
                lblLastName.Text  = lastName;
            }
        }
    }

}
These are the labels on the ShowContactData.aspx page:
        <asp:Label ID="lblFirstName" runat="server"></asp:Label>
        <br />
        <asp:Label ID="lblLastName" runat="server"></asp:Label>
Next
Reply
Map
View

Click here to load this message in the networking platform