【问题标题】:ASPX - Reading master page element returns nullASPX - 读取母版页元素返回 null
【发布时间】:2023-02-02 23:20:44
【问题描述】:

我在母版页中有一个锚链接,并试图在后面的代码中分配它的href,但元素是null

默认.master

<body>
   <header>
      <asp:Hyperlink ID="ancLogout" runat="Server" Text="Logout" />
   </header>
</body>

默认.master.cs

protected void Page_Load(object sender, EventArgs e)
{
  if (ancLogout != null)
    {
      ancLogout.NavigateUrl = String.Format("{0}?logout=1", HttpContext.Current.Request.Url.AbsoluteUri); 
    }
}

ancLogout 始终为空。

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    刚刚尝试了您的确切代码,对我来说没有问题吗? ...可能是服务器上的小写“S”,但无关紧要

    【讨论】:

      猜你喜欢
      • 2015-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多