Asp.net 显示/隐藏包含文件中的HTML表格行

Asp.net 显示/隐藏包含文件中的HTML表格行,asp.net,vb.net,Asp.net,Vb.net,我有一个页面(Default.aspx),它使用一个包含文件来显示左侧导航栏的内容 <asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder_leftnav" Runat="Server"> <!--#include file="../../includes/menus/left_nav/menu.htm" --> </asp:Content> 在menu.htm中,我

我有一个页面(Default.aspx),它使用一个包含文件来显示左侧导航栏的内容

<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder_leftnav" Runat="Server">
    <!--#include file="../../includes/menus/left_nav/menu.htm" -->
</asp:Content>

在menu.htm中,我有一个HTML表格。我只想为某些用户显示一个菜单项(表行),因此我将其设置为
display:none

在Default.aspx的codebehind中,如果用户在允许用户列表中,我想更改该表行的
display
属性,但我不知道如何访问它。有什么想法吗?有更好的方法吗


提前感谢。

重构此功能的快速方法可能是将菜单转换为包含易于操作的表控件的用户控件:

<%@ Register TagPrefix="uc" TagName="Menu" Src="~/Menu.ascx" %>
<asp:Content runat="server" ID="Content4" ContentPlaceHolderID="ContentPlaceHolder_leftnav">
    <uc:Menu runat="server" id="ucMenu" />
</asp:Content>

在asp.net中,在这些情况下通常使用用户控件。请看这里了解详细信息:这个问题似乎也很相似:我想我可能不得不转换成这个问题。谢谢@sr28Hey,因为这是对我所上的一个现有网站的修复,所以对另一个问题的回答非常有效,节省了我的时间。谢谢@SR28没问题,很高兴我能帮忙。
<asp:Table ID="tblMenu" runat="server">
    <asp:TableRow ID="trSecured" runat="server">
        <asp:TableCell ID="tdSecured">Secured (Make Hyperlink)</asp:TableCell>
    </asp:TableRow>
    <asp:TableRow ID="trNonSecured1">
        <asp:TableCell ID="tdNonSecured">Non-Secured (Make Hyperlink)</asp:TableCell>    
    </asp:TableRow>
</asp:Table>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'CanViewSecuredPage should be in it's own class so you can share it between menu display
        'logic and for securing the actual page itself (in case they navigate directly by URL).
        If Not CanViewSecuredPage() Then

            Dim tblTable As Table = CType(Me.FindControl("tblMenu"), Table)

            'Or do .FindControl to not be bound to ordinal.
            tblTable.Rows(0).Visible = False

        End If

    End Sub