Skip to content

question about <form>, asp.net and form layouts #3399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sgarratt opened this issue May 8, 2012 · 1 comment
Closed

question about <form>, asp.net and form layouts #3399

sgarratt opened this issue May 8, 2012 · 1 comment
Labels

Comments

@sgarratt
Copy link

sgarratt commented May 8, 2012

I am using bootstrap in an asp.net app, and absolutely loving it. I ran into an issue, which I solved .. but I really wanted to know if anyone sees any red flags with my solution.

The issue is, asp.net demands that there is one <form> tag, with attribute runat="server" for their code behind stuff to work properly. I was using multiple <form class="form-horizontal"></form>'s on a page, but as only one <form> can exist with attribute runat="server" (or asp.net errors out) only the controls within the one <form runat="server"> would get enabled for code behind.

My first solution was to wrap multiple <form>'s in one enclosing <form runat="server"> but nested form tags create a problem, as HTML validation actively rejects them, and they were ignored (by firefox) and my styling went awry. (looked at view source and DOM after render, only parent <form> was regarded)

So I did this .. I used one and only one enclosing <form runat="server">, and then used div's instead of forms for control grouping . .eg <form runat="server">...<div class="form-horizontal">...</div><div class="form-horizontal">...</div></form> .. and everything seems to look and work just fine. (left out row and span divs for brevity)

so my question is .. is there any problem with using <div class="form-horizontal"> .. specifically using class "form-horizontal" with div's. .. it works fine as far as i can tell so far, and I tried firefox/chrome/IE with good results .. but i'm no CSS expert so i'm concerned.

@mdo
Copy link
Member

mdo commented May 12, 2012

You can use those classes anywhere and on any element. They're designed to work first and foremost with form, but div is fine.

@mdo mdo closed this as completed May 12, 2012
@cvrebert cvrebert added the css label Jan 13, 2015
@twbs twbs locked and limited conversation to collaborators Jan 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants