Show/Hide something in Usercontrol? How to?

  • Thread starter Thread starter Lynn
  • Start date Start date
L

Lynn

Hello,

I have a user control that contains a table, and some text fields. I would
like to show or hide a particular row of this table, based on a selection
the user makes on my page.

Here's the situation...I have a page that has some panels that are hidden.
The first panel is visible...the user selects a city, and presses submit.

The next panel is made visible, and in this panel I have placed a user
control.

If the user selected San Francisco as their city in the first panel, I want
my user control to show a particular row of the table. If they have not
selected San Francisco, then I don't want that row in my user control to
show up for the user to see.

Is there an elegant way to do this?

Thanks for the help!

Lynn
 
Hi Lynn,

Any server-side control have the visible property... maybe you can use it ?
If the control have a view state the visible will be keep during postback.

If you need to hide full html table, just make it server side.

------------ on aspx code

<table id="tableToHide" runat="server">
<tr><td>
......
</td></tr>


----------- on code behind

Dim tableToHide As HtmlControls.HtmlTable

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

tableToHide.Visible = False

End Sub
 
Hi JC,

I have tried this code, and I am getting an error..
"Object reference not set to an instance of an object. "

Line 24:
Line 25: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Line 26: myTable.Visible = False
Line 27: End Sub
Line 28:

I have Dim myTable As HtmlControls.HtmlTable in my code behind page...

Any idea what I would be doing wrong?

Thank you,

Lynn
 
Back
Top