Show/Hide something in Usercontrol? How to?

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
 
J

Jc Morin

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
 
L

Lynn

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
 

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,778
Messages
2,569,605
Members
45,237
Latest member
AvivMNS

Latest Threads

Top