我有一个视觉基本网站,在其中一个页面中,出于某种原因,当我查看代码隐藏时,对每个元素的引用都加下划线(使用visual studio 2015)并给我一个“未声明”的消息。这才刚刚开始。我根本没有对代码进行任何更改。以下是我的样本:
在我的pay_web.aspx中:
<div id="container">
<section class="banner_media_full page_banner" role="banner" id="banner">
<div class="row">
<div id="banner_full">
<h1>Get Started</h1>
</div>
</div>
</section>
<article class="row" id="content">
<div>
<asp:Label ID="lblErrMsg" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>
这是我背后的代码:
Protected Sub Page_Load(sender As Object, e As EventArgs)
Try
Dim li As System.Web.UI.HtmlControls.HtmlGenericControl = DirectCast(Me.Page.Master.FindControl("liGS"), System.Web.UI.HtmlControls.HtmlGenericControl)
li.Attributes.Add("class", "current-menu-item")
Catch ex As Exception
lblErrMsg.Text = "!" & ex.Message.ToString()
End Try
就代码隐藏而言,元素lblErrMsg是未定义的。
我完全失败了。如果你想看,我可以提供完整的页面代码。
感谢您的任何建议。 乔纳森
答案 0 :(得分:0)
我不明白为什么,但如果我以管理员身份在Visual Studio中打开我的网站,我就没有这个问题。因此,我将以管理员身份打开网站并继续前进。