Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide tr or td in a table using vb.net in codebehind

Tags:

asp.net

vb.net

In my masterpage I have links for users also the authorization is different like admin and regular user.

links under each other and I can hide the hyperlinks depending on authorization status but the problem is i.e when I have 3 links the second link for the admin the link will hide when the user is regular and the link place empty like 123 1 3.

So I have an idea using table each link in one tr but I can`t hide td or tr because Visible is not in properties.

any help? thank you

like image 967
ITTIHAD FC. Avatar asked Jun 25 '26 20:06

ITTIHAD FC.


2 Answers

According to how to hide a having asp.net control:

you can give ID either to the TD or TR to which you want to hide/show with the runat="server" and also you can take that tr/td inside the div tag and give id to that div tag and also runat=server attribute and after that you can pro grammatically hide/show that div.

like

<pre>

<tr id="trhide" runat="server"> </tr>

</pre> 

in code behind write

trhide.visible=true/false
like image 71
Vignesh Kumar A Avatar answered Jun 27 '26 09:06

Vignesh Kumar A


In the master page VB code behind add a public procedure: Then call the public set from your aspx page.

'======================================================================================================
    'Set Tab No invisible
    '======================================================================================================
    Public Sub setTabNumberLabel(visible As Int16)
        If visible = 0 Then
            td_page.Visible = False
        Else
            td_page.Visible = True
        End If
    End Sub

The master aspx would be:

   <table style="width:100%">
        <!--<tr style="background-color:#565656;">-->
        <tr>
            <td style="width:15%;text-align:left;vertical-align:bottom;padding-left:20px;">Stategic Energy Assessment ( <asp:Label ID="lbl_year_ended" runat="server" /> )</td>
            <td style="text-align:center;vertical-align:bottom;"><asp:Label ID="lbl_utility_name_and_id" runat="server" /></td>
            <td id="td_page" runat="server" style="width:15%;text-align:right;vertical-align:bottom;padding-right:20px;">Tab No:&nbsp;<asp:Label ID="lbl_page" runat="server" /></td>
        </tr>
        <tr><td colspan="3" style="vertical-align:central"><hr /></td></tr>
        <tr>
            <td style="width:15%;text-align:left;vertical-align:central">
                <asp:Label ID="lbl_print_version" runat="server" Text="View Printable Vision" Visible="false" />
            </td>
            <td style="font-size:larger; font-weight:bold; text-align:center; text-transform:capitalize;vertical-align:central">
                <asp:Label ID="lbl_schedule_name" runat="server" />
            </td>
            <td style="width:15%;text-align:right;vertical-align:central;padding-right:20px;">
                <asp:LinkButton ID="btn_footnotes" runat="server" Visible="false">Footnotes</asp:LinkButton>
                &nbsp;
                </td>
            </tr>
        <%--<tr><td colspan="3" style="vertical-align:central" class="auto-style1"></td></tr>--%>
        <tr><td colspan="3" style="vertical-align:central; padding-right:20%;padding-left:20%; ">
            <i><asp:Label ID="lbl_headnotes" runat="server" Text="" /></i></td></tr>
        <tr><td colspan="3" style="vertical-align:central"><hr /></td></tr>
    </table>
like image 38
user7222005 Avatar answered Jun 27 '26 09:06

user7222005



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!