Asp.net mvc MVC部分视图注册按钮控制操作不适用
我正在使用MVC部分视图。我有两个页面AddPoll.cshtml和Listpoll.cshtml。页面AddPoll.cshtml使用局部视图。 我使用AddPoll:partial view页面将部分视图与Listpoll一起放置Asp.net mvc MVC部分视图注册按钮控制操作不适用,asp.net-mvc,razor,Asp.net Mvc,Razor,我正在使用MVC部分视图。我有两个页面AddPoll.cshtml和Listpoll.cshtml。页面AddPoll.cshtml使用局部视图。 我使用AddPoll:partial view页面将部分视图与Listpoll一起放置 @Html.Partial("/Areas/admin/Views/Poll/AddPoll.cshtml",new Mvc_baker.Areas.admin.Models.pollquestion()); AddPoll.cshtml @model Mvc_
@Html.Partial("/Areas/admin/Views/Poll/AddPoll.cshtml",new Mvc_baker.Areas.admin.Models.pollquestion());
AddPoll.cshtml
@model Mvc_baker.Areas.admin.Models.pollquestion
<link href="~/Content/bootstrapvalidform.css" rel="stylesheet" />
@using (Html.BeginForm(actionName: "AddPoll", controllerName: "Poll"))
{
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<form class="">
<div class="col-md-6">
<div class="panel panel-primary">
<label class="control-label">پرسش</label>
@Html.TextBoxFor(m => m.QuestionText, new { id = "Name",style="width:450px", @class = "form-control" })
@Html.ValidationMessageFor(m => m.QuestionText)
<input class="btn btn-primary btn-default" name="commit" value="register" type="submit">
</div>
</div>
</form>
}
@model Mvc\u baker.Areas.admin.Models.pollquestion
@使用(Html.BeginForm(actionName:“AddPoll”,controllerName:“Poll”))
{
@Html.ValidationSummary(true,“,new{@class=“text danger”})
پرسش
@TextBoxFor(m=>m.QuestionText,新的{id=“Name”,style=“width:450px”,@class=“form control”})
@Html.ValidationMessageFor(m=>m.QuestionText)
}
单击“注册”按钮时,控制操作不适用
当控件上的断点操作和我无法运行时,您似乎有两个嵌套的html表单,它们是无效的标记。
Html.BeginForm
帮助程序已经生成了一个
标记。所以你应该摆脱内在的形式
@model Mvc_baker.Areas.admin.Models.pollquestion
<link href="~/Content/bootstrapvalidform.css" rel="stylesheet" />
@using (Html.BeginForm(actionName: "AddPoll", controllerName: "Poll"))
{
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="col-md-6">
<div class="panel panel-primary">
<label class="control-label">پرسش</label>
@Html.TextBoxFor(m => m.QuestionText, new { id = "Name",style="width:450px", @class = "form-control" })
@Html.ValidationMessageFor(m => m.QuestionText)
<input class="btn btn-primary btn-default" name="commit" value="register" type="submit" />
</div>
</div>
}
@model Mvc\u baker.Areas.admin.Models.pollquestion
@使用(Html.BeginForm(actionName:“AddPoll”,controllerName:“Poll”))
{
@Html.ValidationSummary(true,“,new{@class=“text danger”})
پرسش
@TextBoxFor(m=>m.QuestionText,新的{id=“Name”,style=“width:450px”,@class=“form control”})
@Html.ValidationMessageFor(m=>m.QuestionText)
}
这有效吗?我已经测试过没有差异,我删除了我的表单,但没有更改