When creating an mvc3 project, I found that some page form labels were not generated (using the @ HTML method), so I had to hand-Write the native form label. Today I decided to find the problem.
My page is like this. A Layout page contains several rendersections and a renderbody.
<body> @RenderPage("~/Views/Shared/_top.cshtml") @if (IsSectionDefined("topnav")) { @RenderSection("topnav"); } <!--main start--> @RenderBody() <!--main end--> @if (IsSectionDefined("friendlink")) { @RenderSection("friendlink", false); } @RenderPage("~/Views/Shared/_Footer.cshtml") @if (IsSectionDefined("footjs")) { @RenderSection("footjs", required: false); }</body>
Then, on the page, I start to write @ using (html. beginform ()){}
I couldn't write it out, so I started to minimize the test, deleted all the code, and wrote beginform.
Then I started to add code A LITTLE BIT and finally found the problem. My inner page is like this:
@ Section topnav {@ renderpage ("~ /Views/shared/_ headtab. cshtml ", new {current =" guahao "}) @ renderpage ("~ /Views/shared/_ nav. cshtml ", new {step =" member center "})} <Div class =" u_leftbar ">@renderpage ("~ /Views/shared/wedget/_ guide. cshtml ") @ renderpage ("~ /Views/shared/wedget/_ reservetype. cshtml ") </div> <Div id =" Main "> @ using (HTML. beginform ()){//....} <div>
It can be seen that I render four pages, and the problem is above this. What are the differences between the four partialviews?
The difference is that the partialview in the section is rendered by the rendersection method outside the renderbody, while the part written in the DIV label is rendered by the renderbody, when I write the two renderpages into the section, the form tag appears.
This certainly does not solve the problem. The section contains a placeholder and does not guarantee the association with the content layout in the body. Of course, you cannot simply drop the renderpage into the section, in this case, this modular layout also promotes the significance. Originally, it was easy to load various pendants by loading some views, and it is obviously not suitable to write HTML code, so I used the method of loading some views to solve the problem:
<div class="u_leftbar"> @Html.Partial("~/Views/Shared/Wedget/_Guide.cshtml") @Html.Partial("~/Views/Shared/Wedget/_ReserveType.cshtml")</div>