The form tags aren't displaying. 开发者_如何学JAVA(Really ripping my hair out over this.) I have a view (Index.cshtml):
@section mainmid
{
@using (Html.BeginForm("index", "PetSittingRequest"))
{
<h1>
@Html.TextBox("awesome")
</h1>
}
}
And in my _Layout.cshtml:
@RenderSection("mainmid", required: false)
@RenderBody()
The HTML that I'm getting is this. It has no form tags. They're not located anywhere in the HTML source.
<h1>
<input id="awesome" name="awesome" type="text" value="" />
</h1>
Any thoughts? Thanks!
Impossible to reproduce. Steps:
- Create a new ASP.NET MVC 3 project
In
_Layout.cshtml
replace@RenderBody()
with:@RenderSection("mainmid", required: false) @RenderBody()
In
Index.cshtml
put the following:@section mainmid { @using (Html.BeginForm("index", "PetSittingRequest")) { <h1> @Html.TextBox("awesome") </h1> } }
- Run the application
Browse the source and you will find the correct HTML rendered:
<form action="/PetSittingRequest" method="post"> <h1> <input id="awesome" name="awesome" type="text" value="" /> </h1> </form>
Conclusion: your problem lies somewhere else. So next time you ask a question please provide a full example allowing to reproduce the problem (as I did in my answer).
精彩评论