using code behind model how have conditional code in aspx

S

Support

Hello:
USing the code behind model, i do not understand how to do a conditinal
space in the aspx page. For example: I have two tables, under condition 1 I
want table 1 to show and under condition 2 I want table 2 to show. Place
holders wont work for me. In the old asp environment, this was easy because
both presentation and logic were in the same file but I do not understand
how to do this.
I guess in the vb/dll, I could do a response.write but if your table a
complex it is a pain to do it that way.
Should I use DIVs and set their visibility ? (I am concerned about browser
support - this needs to work for all browsers...)
Thanks
Terry
 
W

Wilco Bauwer

You can conditionally set the visibility of your controls. Your table
should have a runat="server" attribute, and have an ID so you can refer
to it from your codebehind (or put it inside some container, like a
PlaceHolder). Then its just a matter of setting the Visible property.

On a side node: in 2.0 there'll be a multiview control which makes it a
more convenient to switch between views.
 
P

Patrice

Use the Visible porperty. It also to tell if the control should be rendered.
If set to false no HTML code is written....

Patrice
 
B

Brock Allen

Don't call Response.Write -- that's the old way ;)

You can just set the Visible propery of the control so that it will or won't
render to the browser. All server side controls have this property -- including
the PlaceHolder and HtmlTable controls.
 
S

Support

This code behind is such a mess....

I am using a table as a data entry placement structure so you are suggesting
I must write at each load the table structure, the labels, the textboxes and
populate them, etc...
Dim r As HtmlTableRow
Dim c As HtmlTableCell

BUT I really would like to use an existing - completed - table structure
and render it visible or not... like using a DIV but serverside ... if I use
runat="server" it appears I must re-write this table every time ...etc....

This is a complex daqtaentry table with many fields and validation...

I am confused! sorry / Is there a way I can "Blockout" table2 ?

<table id="table1">
<tr><td>Title</td><td><asp:textbox id="tbvcENGPORTALPEOPLEtitle"
runat="server" size="40"></asp:textbox></td></tr>
<tr><td>First Name</td><td><asp:textbox id="tbvcENGPORTALPEOPLEFirstName"
runat="server" size="40"></asp:textbox></td></tr>
</table>

<table id="table2">
<tr><td>More Info</td><td><asp:textbox id="tbvcENGPORTALPEOPLEmoreinfo"
runat="server" size="40"></asp:textbox></td></tr>
<tr><td>More Infor Again</td><td><asp:textbox
id="tbvcENGPORTALPEOPLEmoreinforagain" runat="server"
size="40"></asp:textbox></td></tr>
</table>
 
P

Patrice

Try around :

http://samples.gotdotnet.com/quickstart/aspplus/doc/webdatalist.aspx

You should find here some samples that should help, you to better pick how
ASP.NET works...

Patrice

--

Support said:
This code behind is such a mess....

I am using a table as a data entry placement structure so you are suggesting
I must write at each load the table structure, the labels, the textboxes and
populate them, etc...
Dim r As HtmlTableRow
Dim c As HtmlTableCell

BUT I really would like to use an existing - completed - table structure
and render it visible or not... like using a DIV but serverside ... if I use
runat="server" it appears I must re-write this table every time ....etc....

This is a complex daqtaentry table with many fields and validation...

I am confused! sorry / Is there a way I can "Blockout" table2 ?

<table id="table1">
<tr><td>Title</td><td><asp:textbox id="tbvcENGPORTALPEOPLEtitle"
runat="server" size="40"></asp:textbox></td></tr>
<tr><td>First Name</td><td><asp:textbox id="tbvcENGPORTALPEOPLEFirstName"
runat="server" size="40"></asp:textbox></td></tr>
</table>

<table id="table2">
<tr><td>More Info</td><td><asp:textbox id="tbvcENGPORTALPEOPLEmoreinfo"
runat="server" size="40"></asp:textbox></td></tr>
<tr><td>More Infor Again</td><td><asp:textbox
id="tbvcENGPORTALPEOPLEmoreinforagain" runat="server"
size="40"></asp:textbox></td></tr>
</table>
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top