Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. All Web controls must be placed within a <form runat="server"> tag to function properly.

All Web controls must be placed within a <form runat="server"> tag to function properly.

Scheduled Pinned Locked Moved ASP.NET
sysadmin
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elane
    wrote on last edited by
    #1

    Hi I am confused regarding the statement All Web controls must be placed within a

    tag to function properly. I have added the following to a webform in the code behind I have the following Literal1.Text = "Hello World"; I do not have the web contorl within tag so how come it works. I have also found that I can place other web controls on a web page and not have them between a tag and they work fine. I would appreciate it if some one can explain this to me Kind Regards

    P G 2 Replies Last reply
    0
    • E elane

      Hi I am confused regarding the statement All Web controls must be placed within a

      tag to function properly. I have added the following to a webform in the code behind I have the following Literal1.Text = "Hello World"; I do not have the web contorl within tag so how come it works. I have also found that I can place other web controls on a web page and not have them between a tag and they work fine. I would appreciate it if some one can explain this to me Kind Regards

      P Offline
      P Offline
      Pradipta Basu
      wrote on last edited by
      #2

      Hi, It also confused me initially. But what I found is that, only those web controls which needs a form tag to function are needed to be placed inside a form with Runat="server" attribute. I mean to say, when a form is submitted the value of the controls which will be posted back are of the above type. Thus textbox need to placed inside a form with runat="server" but for a label it is not mandatory. I hope this answers your question. Thanks,

      Pradipta Basu

      1 Reply Last reply
      0
      • E elane

        Hi I am confused regarding the statement All Web controls must be placed within a

        tag to function properly. I have added the following to a webform in the code behind I have the following Literal1.Text = "Hello World"; I do not have the web contorl within tag so how come it works. I have also found that I can place other web controls on a web page and not have them between a tag and they work fine. I would appreciate it if some one can explain this to me Kind Regards

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        Only the controls that are rendered as form fields in the html code need to be inside the form to work. The reason they do is that when the form is posted, only the data from the fields that are within the form is included in the request.

        --- single minded; short sighted; long gone;

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups