Run-time error: <Control Name> must be placed inside a form tag with runat=server

Discussion in 'ASP .Net Web Controls' started by Matthew Louden, Nov 18, 2003.

  1. It happend to me more than once. When I create web controls or move the
    positions in VS.NET, I encountered the following run-time errors: It doesn't
    matter what controls I create, the following 'checkbox' control is just an
    example.


    Control 'CheckBox1' of type 'CheckBox' must be placed inside a form tag with
    runat=server.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Control 'CheckBox1' of type
    'CheckBox' must be placed inside a form tag with runat=server.

    Source Error:

    An unhandled exception was generated during the execution of the current web
    request. Information regarding the origin and location of the exception can
    be identified using the exception stack trace below.


    I know it's very easy to solve the problem, we simply move the code inside
    the form block as follows:

    <form id="Form1" method="post" runat="server">
    'UI code
    </form>

    Maybe it's bug in VS.NET. I just want to see if anyone encountered similar
    problem before.

    Please advise. Thanks!
    Matthew Louden, Nov 18, 2003
    #1
    1. Advertising

  2. Matthew Louden

    Teemu Keiski Guest

    It's not a bug, it's a very much designed feature. Certain controls need to
    exist inside a server form for them to work properly.

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

    "Matthew Louden" <> wrote in message
    news:%...
    > It happend to me more than once. When I create web controls or move the
    > positions in VS.NET, I encountered the following run-time errors: It

    doesn't
    > matter what controls I create, the following 'checkbox' control is just an
    > example.
    >
    >
    > Control 'CheckBox1' of type 'CheckBox' must be placed inside a form tag

    with
    > runat=server.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.Web.HttpException: Control 'CheckBox1' of type
    > 'CheckBox' must be placed inside a form tag with runat=server.
    >
    > Source Error:
    >
    > An unhandled exception was generated during the execution of the current

    web
    > request. Information regarding the origin and location of the exception

    can
    > be identified using the exception stack trace below.
    >
    >
    > I know it's very easy to solve the problem, we simply move the code

    inside
    > the form block as follows:
    >
    > <form id="Form1" method="post" runat="server">
    > 'UI code
    > </form>
    >
    > Maybe it's bug in VS.NET. I just want to see if anyone encountered similar
    > problem before.
    >
    > Please advise. Thanks!
    >
    >
    >
    >
    Teemu Keiski, Nov 18, 2003
    #2
    1. Advertising

  3. Matthew Louden

    Lloyd Sheen Guest

    I know what you mean. I have had more IDE related problems with things like
    this. Everything is ok , move a control and then things are wrong. I think
    the IDE is about where VB2 was. Still not totally ready for prime time.

    I keep losing toolbar buttons etc. and it is very frustrating.


    "Matthew Louden" <> wrote in message
    news:%...
    > It happend to me more than once. When I create web controls or move the
    > positions in VS.NET, I encountered the following run-time errors: It

    doesn't
    > matter what controls I create, the following 'checkbox' control is just an
    > example.
    >
    >
    > Control 'CheckBox1' of type 'CheckBox' must be placed inside a form tag

    with
    > runat=server.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.Web.HttpException: Control 'CheckBox1' of type
    > 'CheckBox' must be placed inside a form tag with runat=server.
    >
    > Source Error:
    >
    > An unhandled exception was generated during the execution of the current

    web
    > request. Information regarding the origin and location of the exception

    can
    > be identified using the exception stack trace below.
    >
    >
    > I know it's very easy to solve the problem, we simply move the code

    inside
    > the form block as follows:
    >
    > <form id="Form1" method="post" runat="server">
    > 'UI code
    > </form>
    >
    > Maybe it's bug in VS.NET. I just want to see if anyone encountered similar
    > problem before.
    >
    > Please advise. Thanks!
    >
    >
    >
    >
    Lloyd Sheen, Nov 18, 2003
    #3
  4. Matthew Louden

    Teemu Keiski Guest

    Or with second reading, if the problem is that IDE moves them out of the
    form, then it could be a bug. :)

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


    "Teemu Keiski" <> wrote in message
    news:%...
    > It's not a bug, it's a very much designed feature. Certain controls need

    to
    > exist inside a server form for them to work properly.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    > "Matthew Louden" <> wrote in message
    > news:%...
    > > It happend to me more than once. When I create web controls or move the
    > > positions in VS.NET, I encountered the following run-time errors: It

    > doesn't
    > > matter what controls I create, the following 'checkbox' control is just

    an
    > > example.
    > >
    > >
    > > Control 'CheckBox1' of type 'CheckBox' must be placed inside a form tag

    > with
    > > runat=server.
    > > Description: An unhandled exception occurred during the execution of the
    > > current web request. Please review the stack trace for more information
    > > about the error and where it originated in the code.
    > >
    > > Exception Details: System.Web.HttpException: Control 'CheckBox1' of type
    > > 'CheckBox' must be placed inside a form tag with runat=server.
    > >
    > > Source Error:
    > >
    > > An unhandled exception was generated during the execution of the current

    > web
    > > request. Information regarding the origin and location of the exception

    > can
    > > be identified using the exception stack trace below.
    > >
    > >
    > > I know it's very easy to solve the problem, we simply move the code

    > inside
    > > the form block as follows:
    > >
    > > <form id="Form1" method="post" runat="server">
    > > 'UI code
    > > </form>
    > >
    > > Maybe it's bug in VS.NET. I just want to see if anyone encountered

    similar
    > > problem before.
    > >
    > > Please advise. Thanks!
    > >
    > >
    > >
    > >

    >
    >
    Teemu Keiski, Nov 18, 2003
    #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. Matthew Louden
    Replies:
    4
    Views:
    13,047
    Teemu Keiski
    Nov 18, 2003
  2. Tom wilson
    Replies:
    7
    Views:
    4,106
    William F. Robertson, Jr.
    Feb 10, 2005
  3. Replies:
    0
    Views:
    2,055
  4. Eliyahu Goldin
    Replies:
    7
    Views:
    260
    Ken Cox [Microsoft MVP]
    Jan 12, 2005
  5. Replies:
    0
    Views:
    625
Loading...

Share This Page