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. Advertising

  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. 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. Wardeaux
    Replies:
    12
    Views:
    775
    Hermit Dave
    Sep 29, 2004
  2. =?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:
    18,733
    Steven Cheng[MSFT]
    Apr 27, 2006
  3. Kevin Blount
    Replies:
    4
    Views:
    796
    Kevin Blount
    Aug 24, 2006
  4. mark4asp
    Replies:
    1
    Views:
    492
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Apr 3, 2007
  5. DC

    Add form runat=server tags in Composite Control

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

Share This Page