0

I've got a page called webform1 and it has a couple of textboxes and a button and I want to pass the data to a couple of labels on webform2.

WebForm1 Button:

    <asp:Button ID="btnCrossPage" runat="server" Text="Button" PostBackUrl="~/Webform2.aspx" />

Code behind webform 1:

        public partial class webform1 : System.Web.UI.Page
    {

    }
    public string Name
    {
      get{ return txtName.Text;}
    }
     public string Email
    {
      get{ return txtEmai.Text;}
    }

Webform2 Code Behind:

    public partial class Webform2: System.Web.UI.Page
    { 
      Webform1 pPage = (Webform1)this.PreviousPage;
      if(pPage != null && pPage.IsCrossPagePostBack)
      {
             lblName.Text = pPage.Name;
             lblEmail.Text = pPage.Email;
      }

Visual Studio is not letting me reference WebForm1 in WebForm2 without a red line appearing, can anyone see a reason why?

  • Visual Studio is not letting me reference WebForm1 in WebForm2 without a red line, can you see a reason why? – user3518737 May 18 '14 at 12:59
  • Have you read this [Microsoft article](http://msdn.microsoft.com/en-us/library/vstudio/6c3yckfw(v=vs.100).aspx)? – Rick S May 18 '14 at 13:01

1 Answers1

0

Well, for once, "webForm1" is misspelled, should be "WebForm1". Also, you can ser the PreviousPageType directive:

<%@ Page Language="C#" PreviousPageType="WebForm1" %>
Ricardo Peres
  • 13,724
  • 5
  • 57
  • 74