在标签中链接到UserControl页面

本文关键字:UserControl 页面 链接 标签 | 更新日期: 2023-09-27 18:09:55

我试图在标签中添加链接到aspx页面UserControl . asx .cs。

链接文本在那里(我可以看到它),但错误是:

CS0103: The name 'All' does not exist in the current context

下面是我在代码中所做的:

.ascx

<asp:Label ID="All" runat="server" Text="All"></asp:Label>

.ascx.cs

  protected void Page_Load(object sender, EventArgs e)
  {
    if (!this.IsPostBack)
      ViewState["LoginErrors"] = 0;
    string UrL = "<a href='http://www.google.com'>www.google.com</a>";
    All.Text = UrL;
  }

在标签中链接到UserControl页面

1-检查你的WebUserControl。ascx你有在Page指令,属性:

Inherits="yourWebApplication.WebUserControl"

2-检查你的 webbusercontrol . asx .designer.cs你有

protected global::System.Web.UI.WebControls.Label All