Reputation: 3
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?
Upvotes: 0
Views: 468
Reputation: 14555
Well, for once, "webForm1" is misspelled, should be "WebForm1". Also, you can ser the PreviousPageType directive:
<%@ Page Language="C#" PreviousPageType="WebForm1" %>
Upvotes: 0