将Label链接到UserControl页面

时间:2014-06-21 08:37:02

标签: c# asp.net

我正在尝试将标签中的链接添加到aspx页面 UserControl .ascx.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;
  }

1 个答案:

答案 0 :(得分:0)

1-检查您在Page指令中的 WebUserControl.ascx 上的attribut:

Inherits="yourWebApplication.WebUserControl"

2-检查 WebUserControl.ascx.designer.cs 上的内容

protected global::System.Web.UI.WebControls.Label All
相关问题