using code behind model how have conditional code in aspx

Discussion in 'ASP .Net' started by Support, Mar 18, 2005.

  1. Support

    Support Guest

    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
     
    Support, Mar 18, 2005
    #1
    1. Advertising

  2. Support

    Wilco Bauwer Guest

    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
     
    Wilco Bauwer, Mar 18, 2005
    #2
    1. Advertising

  3. Support

    Patrice Guest

    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" <> a écrit dans le message
    de news:...
    > 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
    >
    >
     
    Patrice, Mar 18, 2005
    #3
  4. Support

    Brock Allen Guest

    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
     
    Brock Allen, Mar 18, 2005
    #4
  5. Support

    Support Guest

    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" <> wrote in message
    news:...
    > 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
    >
     
    Support, Mar 18, 2005
    #5
  6. Support

    Patrice Guest

    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" <> a écrit dans le message
    de news:%...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >

    >
    >
     
    Patrice, Mar 18, 2005
    #6
  7. Support

    Support Guest

    looks promissing! thanks
    T
    "Patrice" <> wrote in message
    news:%...
    > 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" <> a écrit dans le
    > message
    > de news:%...
    >> 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" <> wrote in message
    >> news:...
    >> > 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
    >> >

    >>
    >>

    >
    >
     
    Support, Mar 18, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    594
    Alphonse Giambrone
    Jun 28, 2003
  2. Paolo Pignatelli
    Replies:
    6
    Views:
    2,197
    Paolo Pignatelli
    Feb 21, 2005
  3. Charlie@CBFC
    Replies:
    1
    Views:
    325
    tdavisjr
    Apr 20, 2006
  4. Alec S.
    Replies:
    10
    Views:
    10,172
    Alec S.
    Apr 16, 2005
  5. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    491
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
Loading...

Share This Page