从母版页 vb 文件引用默认页上的对象
我的“default.aspx”页面中有一个 asp 图像。
我在我的母版页 vb 文件上设置了 cookie,并根据 cookie 设置,我想显示或隐藏此图像。
default.aspx
<asp:image ImageUrl="/images/myimage.jpg" runat="server" ID="myimage" Visible="false"></asp:image>
mymaster.aspx.vb
Private Function getFreeCallNumber(ByVal value As String) As String
Select Case value
Case "MYCASE"
myimage.visible = true
End Select
End Function
我收到以下错误:
'myimage' 未声明。由于其保护级别,它可能无法访问。
有什么想法为什么,更重要的是,如何阻止它?
I have an asp image within my "default.aspx" page.
I set cookies on my masterpage vb file and depending on the cookie set, I want to show or hide this image.
default.aspx
<asp:image ImageUrl="/images/myimage.jpg" runat="server" ID="myimage" Visible="false"></asp:image>
mymaster.aspx.vb
Private Function getFreeCallNumber(ByVal value As String) As String
Select Case value
Case "MYCASE"
myimage.visible = true
End Select
End Function
I get the following error:
'myimage' is not declared. It may be inaccessible due to its protection level.
Any ideas why, and more importantly, how to stop it??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
母版页无权访问使用它的内容页。由于可能有许多内容页使用此母版页,当实际内容页不是
default.aspx
时,母版页谈论myimage
意味着什么?如果此图像要为所有使用该母版页的页面所共用,请将其放在母版页上。
如果您希望每个页面都有不同的图像,请在母版页上创建一个
ContentPlaceHolder
并让内容页面将其图像放在那里 - 然后控制ContentPlaceHolder
的可见性来自母版页代码隐藏。The master page doesn't have access to the content pages that use it. Since there are potentially many content pages using this master page, what would it mean for the master page to talk about
myimage
, when the actual content page is notdefault.aspx
?If this image is intended to be common to all pages that use this master page, put it on the master page.
If you want each page to have a different image, create a
ContentPlaceHolder
on the master page and let the content pages put their image in there - then control the visibility of theContentPlaceHolder
from the master page codebehind.