Adding "form runat server" from codebehind..

Discussion in 'ASP .Net Building Controls' started by John, Oct 13, 2003.

  1. John

    John Guest

    Hi..

    I'm creating a "Web Custom Control" and need to generate a
    form. I can't put the form tag's to the aspx-fil. I have
    to generate them from the webcontrol.

    I understand that this code wont work:

    Protected Overrides Sub Render(ByVal output As
    HtmlTextWriter)
    output.AddAttribute("runat", "server")
    output.AddAttribute("ID", "MainForm")
    output.RenderBeginTag(HtmlTextWriterTag.Form)
    'My form-controls
    output.RenderEndTag
    End Sub

    But how can I do this??

    Regards,
    John
     
    John, Oct 13, 2003
    #1
    1. Advertisements

  2. John

    Teemu Keiski Guest

    Have you seen this thread at ASP.NET Forums?
    http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=364857

    I.e you would need to add the HtmlForm as child control.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist

    "John" <> wrote in message
    news:010701c39197$a56dedc0$...
    > Hi..
    >
    > I'm creating a "Web Custom Control" and need to generate a
    > form. I can't put the form tag's to the aspx-fil. I have
    > to generate them from the webcontrol.
    >
    > I understand that this code wont work:
    >
    > Protected Overrides Sub Render(ByVal output As
    > HtmlTextWriter)
    > output.AddAttribute("runat", "server")
    > output.AddAttribute("ID", "MainForm")
    > output.RenderBeginTag(HtmlTextWriterTag.Form)
    > 'My form-controls
    > output.RenderEndTag
    > End Sub
    >
    > But how can I do this??
    >
    > Regards,
    > John
     
    Teemu Keiski, Oct 16, 2003
    #2
    1. Advertisements

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. Wardeaux
    Replies:
    12
    Views:
    917
    Hermit Dave
    Sep 29, 2004
  2. Lars Netzel
    Replies:
    2
    Views:
    1,003
    Brock Allen
    Apr 7, 2005
  3. =?Utf-8?B?RGF2ZQ==?=

    Adding a .css to <head> tag from codebehind?

    =?Utf-8?B?RGF2ZQ==?=, Apr 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    10,434
    =?Utf-8?B?RGF2ZQ==?=
    Apr 29, 2005
  4. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    <form runat=server> Tag in a MasterPage environment

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Apr 22, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    19,144
    Steven Cheng[MSFT]
    Apr 27, 2006
  5. Kevin Blount
    Replies:
    4
    Views:
    953
    Kevin Blount
    Aug 24, 2006
  6. mark4asp
    Replies:
    1
    Views:
    685
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Apr 3, 2007
  7. Serge

    Adding Server Control dynamically in CodeBehind

    Serge, Sep 22, 2003, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    313
    John Saunders
    Sep 23, 2003
  8. DC

    Add form runat=server tags in Composite Control

    DC, Dec 13, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    327
Loading...