Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form and Site.Master Conflict
Message
From
25/03/2014 12:22:57
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01597264
Message ID:
01597282
Views:
31
>>>>>Hi,
>>>>>I am trying to understand how to get around the following "issue":
>>>>>
>>>>>The ASP.NET Forms project has a Site.Master page which is used in all other pages. The Site.Master page has the "Form" element within the entire Body. And I need the individual pages (that use the Site.Master) to have a "Form" element too where I would set the class "form-horizontal" (for Bootstrap 3) as following:
>>>>>
>>>>><asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
>>>>>
>>>>>     <form class="form-horizontal" id="form1" runat="server">
>>>>>     
>>>>>    </form>
>>>>>
>>>>></asp:Content>
>>>>>
>>>>>
>>>>>But the above "Form" element has the squiggly green line underneath and the message VS 2012 displays is:
>>>>>
>>>>> "Validation (HTML5). Element 'form' must not be nested within element 'form'"   
>>>>>
>>>>>
>>>>>So my question is, how can I have element "form" in the Site.Master page and in the content page that uses the Master page? Or should I do away with element "form" in the Site.Master?
>>>>>
>>>>>TIA
>>>>>
>>>>>UPDATE: Let me rephrase the question as following. Since I cannot have the "form" tag in the Master and a Content page, what if I just add the class="form-horizontal" to the Master page "form" element. I think that the content pages that need this class will be "happy." But what type of Content page could be "messed up" by the class="form-horizontal"?
>>>>>
>>>>>UPDATE 2: I just thought about another approach. What if I add jQuery to the pages that need the class="form-horizontal" to add the class "form-horizontal" to the "form" element? (using jQuery .AddClass). This way, the content pages that do not need the class "form-horizontal" will not have it and the ones that do will. Does it make sense?
>>>>
>>>>Yup. Except that it seems a bit unusual that all content would need to be form based?
>>>
>>>Why is it unusual? Or maybe I don't understand what you mean by "all content would need to be form based".
>>
>>Generalizing a bit - but forms are mainly for user input and, on most web-sites, there's only a small number of pages requiring that so I'd tend to only specify the form element in the view when it was required....
>
>I see. But in my case I am working on a database application where most (I would guess 90%) of forms are for the purposes of user entering data.

Fair enough. I did say it was unusual - not unheard of :-}

But, on reflection I'd still lean towards keeping the form tag in the view. You mentioned one thing that might vary between forms (the 'form-horizontal' class) and there may be other classes or attributes which would need to be selectively applied. Doing that via javascript could become messy and there's not real downside (other than a couple of lines of html) to keeping the form tag in the view.....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform