Dynamic Web Control Creation

Discussion in 'ASP .Net Web Controls' started by Ryan Wade, Oct 8, 2004.

  1. Ryan Wade

    Ryan Wade Guest

    If I put my control on the form in the designer it works
    OK. But If I create it in using response.Write in the
    pageload event it doesn't get created. Any thoughts?

    this.Response.Write("<td>");
    this.Response.Write("<uc1:EnterCase id=\"cEnterCase\"
    runat=\"server\">");
    this.Response.Write("</uc1:EnterCase>");
    this.Response.Write("</td>");
     
    Ryan Wade, Oct 8, 2004
    #1
    1. Advertising

  2. When you use Response.Write, you're just writing text to the Web browser. It
    is far to late - and in the wrong place - for the ASP.NET engine to interpret
    it as code and generate output.


    "Ryan Wade" wrote:

    > If I put my control on the form in the designer it works
    > OK. But If I create it in using response.Write in the
    > pageload event it doesn't get created. Any thoughts?
    >
    > this.Response.Write("<td>");
    > this.Response.Write("<uc1:EnterCase id=\"cEnterCase\"
    > runat=\"server\">");
    > this.Response.Write("</uc1:EnterCase>");
    > this.Response.Write("</td>");
    >
    >
     
    Ken Cox [Microsoft MVP], Oct 8, 2004
    #2
    1. Advertising

  3. Ryan Wade

    Ryan Wade Guest

    I'm very new to asp.net and don't know much. Where is the
    best place to put my controls creation?


    >-----Original Message-----
    >When you use Response.Write, you're just writing text to

    the Web browser. It
    >is far to late - and in the wrong place - for the ASP.NET

    engine to interpret
    >it as code and generate output.
    >
    >
    >"Ryan Wade" wrote:
    >
    >> If I put my control on the form in the designer it

    works
    >> OK. But If I create it in using response.Write in the
    >> pageload event it doesn't get created. Any thoughts?
    >>
    >> this.Response.Write("<td>");
    >> this.Response.Write("<uc1:EnterCase id=\"cEnterCase\"
    >> runat=\"server\">");
    >> this.Response.Write("</uc1:EnterCase>");
    >> this.Response.Write("</td>");
    >>
    >>

    >.
    >
     
    Ryan Wade, Oct 8, 2004
    #3
  4. Hi Ryan,

    I suspect you'd do better with inserting a Placeholder control in your table
    cell and then dynamically adding whatever other controls you need. There's
    some sample code on this documentation page that shows how to add a control
    to the Placeholder's Controls collection:

    http://msdn.microsoft.com/library/d...skaddingplaceholdercontrolstowebformspage.asp

    Ken



    "Ryan Wade" wrote:

    > I'm very new to asp.net and don't know much. Where is the
    > best place to put my controls creation?
    >
    >
    > >-----Original Message-----
    > >When you use Response.Write, you're just writing text to

    > the Web browser. It
    > >is far to late - and in the wrong place - for the ASP.NET

    > engine to interpret
    > >it as code and generate output.
    > >
    > >
    > >"Ryan Wade" wrote:
    > >
    > >> If I put my control on the form in the designer it

    > works
    > >> OK. But If I create it in using response.Write in the
    > >> pageload event it doesn't get created. Any thoughts?
    > >>
    > >> this.Response.Write("<td>");
    > >> this.Response.Write("<uc1:EnterCase id=\"cEnterCase\"
    > >> runat=\"server\">");
    > >> this.Response.Write("</uc1:EnterCase>");
    > >> this.Response.Write("</td>");
    > >>
    > >>

    > >.
    > >

    >
     
    Ken Cox [Microsoft MVP], Oct 8, 2004
    #4
    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. Jeff Voigt

    Dynamic Control Creation w/Events?

    Jeff Voigt, Jul 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    368
    Natty Gur
    Jul 8, 2003
  2. PABruceFan
    Replies:
    3
    Views:
    4,128
    John Saunders
    Jul 31, 2004
  3. =?Utf-8?B?UGF1bA==?=

    Dynamic control creation design issue

    =?Utf-8?B?UGF1bA==?=, Feb 21, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    427
    =?Utf-8?B?UGF1bA==?=
    Feb 21, 2006
  4. Hugo Flores
    Replies:
    1
    Views:
    499
    daniel #
    Sep 6, 2006
  5. injy
    Replies:
    0
    Views:
    229
Loading...

Share This Page