Show and hide a usercontrol (codebehind)

Ø

Øyvind Isaksen

Is it possible to show/hide a usercontrol code behind?
<uc1:topart id="Topart1" runat="server"></uc1:topart>


This is what i want to do, but this does not work:

if objDR.read
me.Topart1.show 'Show usercontrol if datareader.read
else
me.Topart1.hide 'Hide usercontrol
end if


Thanks for your tips!!!
 
J

JDP@Work

When I want to display different datagrids or fields, rather than create or not,
I place the controls in panels

<asp:panel....

I then enable or disable the visiblity of the panel that contains the UC.

I've created wizards this way and even forms using a table that has panels in
the cells.

I've even used the <tr> as <asp:TR> and have two sProcs exec, one for the UI and
the other for the data.

Certain rows w/in my table are referenced in the UI sProc and stored in SQL.

This also gives me the abilty to build an Admin interface for the cotrols that
doesn't require a build.

I can then hide a row that has say 2 cells, lable and form field that is not
supposed to conditionally disply for a certain record types.

HTH

JeffP....
 
D

Dan

Hi

I think J gave you way more than you need and slightly veered from a simple
hide/show.

Yes it can be done, i am a c# man but i can't see the code being very diff,
you simply set the components Visible flag to false.

First check that it does vanish by simply running the code with no if
statement, then put in the if statement. Or set a breakpoint inside it to
ensure the partt hat hides it is being called. It may well be that and not
your flag setting.

Hope that helps
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top