How do I make a table cells visibility depend on a session variable?

C

COHENMARVIN

I have a table with 2 buttons in it - a SAVE button and a DELETE
button. If Session("BothButtons") = True, I want to show both buttons.
If Session("BothButtons") = False, I want to show only the SAVE button.
This would be easy to do (I just would set DeleteButton.Visible =
False), but the problem is that the 2 buttons are in 2 different cells
of a table, something like this:
<td align="center"><ASP:Button id="Save" runat="server" /></td>
<td align="center"><ASP:Button id="Delete" runat="server" /></td>
So I want an entire <TD> tag to disappear, along with the button that
is in it.
In regular ASP, you would just say something like:
<%
If Session("BothButtons") = True Then
Response.Write("<td etc....")
Else
Response.Write("<td etc ...")
End If
%>
But I think you cannot do inline code like this in ASP.net. I may be
wrong. Any help from this very helpful forum is appreciated.
Thanks,
Marvin
 
N

needin4mation

You could create an asp:table with associative controls for tables
(asp:tableheader, asp:TableCell...).
 
L

Lucas Tam

<td align="center"><ASP:Button id="Save" runat="server" /></td>
<td align="center"><ASP:Button id="Delete" runat="server" /></td>

Add a runat="server" to the <td> tag (or the <tr> tag depending on how
you've setup your tables).

Then you can turn on/off the cell.

But also make sure you adjust the columnspan too ; )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top