Add div to asp.net page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    Add div to asp.net page

    Hello,

    I want to add a div tag with a few properties (class, id, ...) to a
    page. I would like to build the following block:

    <div id="myid" class="myclass" >

    <Asp:TextBox. ..

    </div>

    I don't want to add the div using Asp:Panel.

    I know I can use literal. But is there another way to define the div
    and its properties before adding it to the page without using a
    string?

    What should be the best way to do this?

    Thanks,

    Miguel

  • Michael Nemtsev

    #2
    Re: Add div to asp.net page

    Hello Shapper,

    use HtmlGenericCont rol like this

    Control control = this.FindContro l("body");
    HtmlControl divControl = new HtmlGenericCont rol("div");
    divControl.Attr ibutes.Add("id" ,"myid");
    divControl.Attr ibutes.Add("cla ss","myclass" );
    control.Control s.Add(divContro l);




    ---
    WBR, Michael Nemtsev [.NET/C# MVP].
    My blog: http://spaces.live.com/laflour
    Team blog: http://devkids.blogspot.com/

    "The greatest danger for most of us is not that our aim is too high and we
    miss it, but that it is too low and we reach it" (c) Michelangelo

    SHello,
    S>
    SI want to add a div tag with a few properties (class, id, ...) to a
    Spage. I would like to build the following block:
    S>
    S<div id="myid" class="myclass" >
    S>
    S<Asp:TextBox.. .
    S>
    S</div>
    S>
    SI don't want to add the div using Asp:Panel.
    S>
    SI know I can use literal. But is there another way to define the div
    Sand its properties before adding it to the page without using a
    Sstring?
    S>
    SWhat should be the best way to do this?
    S>
    SThanks,
    S>
    SMiguel
    S>


    Comment

    Working...