开发者

referencing object on default page from the master page vb file

开发者 https://www.devze.com 2023-04-03 14:28 出处:网络
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.

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 getFreeCallNu开发者_开发百科mber(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??


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 not default.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 the ContentPlaceHolder from the master page codebehind.

0

精彩评论

暂无评论...
验证码 换一张
取 消