B Z
B Z

Reputation: 9453

Asp.Net MVC 3 Razor Rendering Bug?

This one is strange...I have the following markup for a view using Razor view engine ASP.Net MVC 3 RC

            <p>
                <div class="editor-label">
                    @Html.LabelFor(model => model.Client.FirstName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Client.FirstName) @Html.ValidationMessageFor(model => model.Client.FirstName)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.Client.LastName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Client.LastName) @Html.ValidationMessageFor(model => model.Client.LastName)
                </div>
            </p>

The problem is that when it renders, the P tag is not surrounding the DIVs! It renders like this:

<p>
                </p><div class="editor-label">
                    <label for="Client.FirstName">First Name</label>
                </div>
                <div class="editor-field">
                    <input class="text-box single-line" data-val="true" data-val-required="The First Name field is required." id="Client_FirstName" name="Client.FirstName" value="My FName" type="text"> <span class="field-validation-valid" data-valmsg-for="Client.FirstName" data-valmsg-replace="true"></span>
                </div>
                <div class="editor-label">
                    <label for="Client.LastName">Last Name</label>
                </div>
                <div class="editor-field">
                    <input class="text-box single-line" data-val="true" data-val-required="The Last Name field is required." id="Client_LastName" name="Client.LastName" value="My LName" type="text"> <span class="field-validation-valid" data-valmsg-for="Client.LastName" data-valmsg-replace="true"></span>
                </div>

What the heck is going on? Any help is appreciated!

Upvotes: 3

Views: 1068

Answers (3)

Omer Bokhari
Omer Bokhari

Reputation: 59578

a paragraph cannot contain other block level elements. w3c

also check out this question

Upvotes: 4

jvanrhyn
jvanrhyn

Reputation: 2824

The P element represents a paragraph. It cannot contain block-level elements e.g. DIV

Upvotes: 2

B Z
B Z

Reputation: 9453

Hmmm, it seems like it is just standard browser behavior?

http://blog.programmingsolution.net/html/html-div-tag-inside-html-p-paragraph-tag-does-not-work-correctly/

Upvotes: 2

Related Questions