• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 611
  • Last Modified:

hide half of a html table using code behind

Ok this is a html table with a few links, I want to make invisible or better disabled a few of the links using c# code behind.

I tried to split the links in two tables so I could hide the half that I want, the problem is that it wont look normal... It must still be on one line and I wasn't able to accomplish that...  

any help?
<div align="center">
		<table id="AutoNumber2" style="BORDER-COLLAPSE: collapse" borderColor="#111111" cellSpacing="0"
			cellPadding="0" width="775" border="0">
				<td width="7" background="admin_images/white_bg.gif" height="19"></td>
				<td width="6"><IMG height=19 src="admin_images/<%=hleft%>" width=6 border=0 ></td>
				<td width=49 background="admin_images/<%=hbg%>" height=19 
					<font style="FONT-SIZE: 8pt" face="Arial"><A class="headerlinks" href="Index.aspx?id=home">Home</font></A>
				<td width="2"><IMG height=19 src="admin_images/<%=hright%>" width=2 border=0 ></td>
				<td width="6"><IMG height=19 src="admin_images/<%=hleft1%>" width=6 border=0 ></td>
				<td width=100 background="admin_images/<%=hbg1%>" height=19 
					<font style="FONT-SIZE: 8pt" face="Arial"><A class="headerlinks" href="Index.aspx?id=searchorders">Order 
				<td width="2"><IMG height=19 src="admin_images/<%=hright1%>" width=2 border=0 ></td>
				<td width="6"><IMG height=19 src="admin_images/<%=hleft2%>" width=6 border=0 ></td>
				<td width=100 background="admin_images/<%=hbg2%>" height=19 
					<font style="FONT-SIZE: 8pt" face="Arial"><A class="headerlinks" href="Index.aspx?id=custmanage">Customer 
				<td width="2"><IMG height=19 src="admin_images/<%=hright2%>" width=2 border=0 ></td>
				<td width="6"><IMG height=19 src="admin_images/<%=hleft3%>" width=6 border=0 ></td>
				<td width=85 background="admin_images/<%=hbg3%>" height=19 
					<font style="FONT-SIZE: 8pt" face="Arial"><A class="headerlinks" href="Index.aspx?id=shippingconfiguration">Configuration</font></A>
				<td width="2"><IMG height=19 src="admin_images/<%=hright3%>" width=2 border=0 ></td>
				<td width="6"><IMG height=19 src="admin_images/<%=hleft4%>" width=6 border=0 ></td>
				<td width=100 background="admin_images/<%=hbg4%>" height=19 
					<font style="FONT-SIZE: 8pt" face="Arial"><A class="headerlinks" href="Index.aspx?id=inventorymanager">Inventory 
				<td width="2"><IMG height=19 src="admin_images/<%=hright4%>" width=2 border=0 ></td>
				<td width="6"><IMG height=19 src="admin_images/<%=hleft5%>" width=6 border=0 ></td>
				<td width=115 background="admin_images/<%=hbg5%>" height=19 
					<font style="FONT-SIZE: 8pt" face="Arial"><A class="headerlinks" href="Index.aspx?id=homepagewelcome">Content 
				<td width="2"><IMG height=19 src="admin_images/<%=hright5%>" width=2 border=0 ></td>
				<td width="6"><IMG height=19 src="admin_images/<%=hleft6%>" width=6 border=0 ></td>
				<td width=115 background="admin_images/<%=hbg6%>" height=19 
					<font style="FONT-SIZE: 8pt" face="Arial"><A class="headerlinks" href="Index.aspx?id=adminedit">Store 
				<td width="2"><IMG height=19 src="admin_images/<%=hright6%>" width=2 border=0 ></td>
				<td width="6"><IMG height=19 src="admin_images/<%=hleft7%>" width=6 border=0 ></td>
				<td width=52 background="admin_images/<%=hbg7%>" height=19 
					<font style="FONT-SIZE: 8pt" face="Arial"><A class="headerlinks" href="Index.aspx?id=adminreportoptions">Reports</font></A>
				<td width="2"><IMG height=19 src="admin_images/<%=hright7%>" width=2 border=0 ></td>

Open in new window

  • 2
1 Solution
Use <asp:Table> instead of HTML table.
Then you can assign IDs to the rows/tds, and manipulate them from code-behind.
If you want to make links disabled, use **onclick="return false"** in the anchor tag. e.g.
<A class="headerlinks" onclick="return false" href="Index.aspx?id=searchorders">

If you want to remove underline also, use **style="text-decoration:none"**
<A class="headerlinks" style="text-decoration:none" onclick="return false" href="Index.aspx?id=searchorders">

if you want to completely hide the links, use **style="display:none"**
<A class="headerlinks" style="display:none" href="Index.aspx?id=searchorders">

if you put the following code in your html:
<style type="text/css">
    a.hide {
        display: none;
    a.dis {
        text-decoration: none;

then styles could be used by applying multiple classes (separated by space) in "class" attribute. e.g
<A class="headerlinks hide" href="Index.aspx?id=searchorders">
<A class="headerlinks dis" onclick="return false" href="Index.aspx?id=searchorders">
JustAskMeAuthor Commented:
EugeneLT: thanks! that makes sense.

Can you give me a sample of the syntax, i could use to make this change?

Thank you  
JustAskMeAuthor Commented:
thanks I figured it out
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now