简体   繁体   中英

Link in a Label to the UserControl page

I am trying to add a link in a Label to the aspx page UserControl .ascx.cs.

The link text is there ( I can see it) but the error is:

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

Here is what I did in code.

.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- Check that on your WebUserControl.ascx you have in the Page directive, the attribut :

Inherits="yourWebApplication.WebUserControl"

2- Check that on your WebUserControl.ascx.designer.cs you have

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM