开发者

asp.net masterpage - make hyperlink visible at runtime

Is it possible to alter the visible prope开发者_运维问答rty of hyperlinks on a masterpage at runtime?

thanks


If you expose the hyperlink as a property on the master page, you can get a reference to a pages master and cast that to your specific master page then set visibility of the hyperlinks using that property.

In your master page have something like this:

Public ReadOnly Property RemitViewerLink() As HyperLink
    Get
        Return hlRemitViewer
    End Get
End Property

Then in your child page you can do this

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim MyMaster As MasterPage = DirectCast(Page.Master, MasterPage)
    MyMaster.RemitViewerLink.CssClass = "selectedMenuItem" 'or set visibility
End Sub


No, if you set visible=False then it won't even display in the HTML output of the page. You would need to use javascript to hide/show the hyperlinks instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜