我有一个名为 webform1 的页面,它有几个文本框和一个按钮,我想将数据传递给 webform2 上的几个标签。
WebForm1 按钮:
<asp:Button ID="btnCrossPage" runat="server" Text="Button" PostBackUrl="~/Webform2.aspx" />
网络表单 1 背后的代码:
public partial class webform1 : System.Web.UI.Page
{
}
public string Name
{
get{ return txtName.Text;}
}
public string Email
{
get{ return txtEmai.Text;}
}
Webform2 代码背后:
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 不允许我在没有出现红线的情况下在 WebForm2 中引用 WebForm1,任何人都可以看到原因吗?