Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cross Page Posting
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01454461
Message ID:
01454464
Views:
44
This message has been marked as the solution to the initial question of the thread.
Assuming the code for Previous page works,

this part
lblFirstName.Text = firstName;
                lblLastName.Text  = lastName;
should be changed to
lblFirstName.Text = firstName.Text;
 lblLastName.Text  = lastName.Text;
>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>
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform