Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > using code behind model how have conditional code in aspx

Reply
Thread Tools

using code behind model how have conditional code in aspx

 
 
Support
Guest
Posts: n/a
 
      03-18-2005
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


 
Reply With Quote
 
 
 
 
Wilco Bauwer
Guest
Posts: n/a
 
      03-18-2005
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.

----
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl

 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      03-18-2005
Use the Visible porperty. It also to tell if the control should be rendered.
If set to false no HTML code is written....

Patrice

--

"Support" <(E-Mail Removed)> a écrit dans le message
de news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Brock Allen
Guest
Posts: n/a
 
      03-18-2005
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen



> 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




 
Reply With Quote
 
Support
Guest
Posts: n/a
 
      03-18-2005
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>



"Wilco Bauwer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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.
>
> ----
> - Wilco Bauwer
> Blog & Custom Controls @ http://wilcoding.xs4all.nl
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      03-18-2005
Try around :

http://samples.gotdotnet.com/quickst...bdatalist.aspx

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

Patrice

--

"Support" <(E-Mail Removed)> a écrit dans le message
de news:%(E-Mail Removed)...
> 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>
>
>
>
> "Wilco Bauwer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > 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.
> >
> > ----
> > - Wilco Bauwer
> > Blog & Custom Controls @ http://wilcoding.xs4all.nl
> >

>
>



 
Reply With Quote
 
Support
Guest
Posts: n/a
 
      03-18-2005
looks promissing! thanks
T
"Patrice" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Try around :
>
> http://samples.gotdotnet.com/quickst...bdatalist.aspx
>
> You should find here some samples that should help, you to better pick how
> ASP.NET works...
>
> Patrice
>
> --
>
> "Support" <(E-Mail Removed)> a écrit dans le
> message
> de news:%(E-Mail Removed)...
>> 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>
>>
>>
>>
>> "Wilco Bauwer" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) oups.com...
>> > 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.
>> >
>> > ----
>> > - Wilco Bauwer
>> > Blog & Custom Controls @ http://wilcoding.xs4all.nl
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
? ELSE Conditional Comment / Using Conditional Comments Inside Other Tags To Comment Out Attributes Alec S. HTML 10 04-16-2005 02:21 AM
How to bring aspx code (in HTML view) to the aspx.vb code-behind? Paolo Pignatelli ASP .Net 6 02-21-2005 01:55 AM
Re: using code behind variables in .aspx Elliot Rodriguez ASP .Net 0 07-31-2003 03:23 PM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments