c# - Referencing another a web form in another web form to pass data -
i've got page called webform1 , has couple of textboxes , button , want pass data 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 not letting me reference webform1 in webform2 without red line appearing, can see reason why?
well, once, "webform1" misspelled, should "webform1". also, can ser previouspagetype directive:
<%@ page language="c#" previouspagetype="webform1" %>
Comments
Post a Comment