Asp.net mvc 3 从局部视图创建元素后,主视图消除了过滤器
Mi的麻烦在于:我有一个叫做“创建”的视图,它指的是创建促销活动。每个促销都有用户的类型,因此,当我进入“创建促销”时,我有一个包含用户类型的列表(下拉列表),但如果没有专业类型,我必须在不离开当前页面的情况下创建它,因此我使用部分视图创建新类型,并将其插入主视图(创建促销)它确实有效,但在创建类型之后,主视图将显示所有类型,而不仅仅是与当前用户对应的类型 这是主要观点:Asp.net mvc 3 从局部视图创建元素后,主视图消除了过滤器,asp.net-mvc-3,partial-views,Asp.net Mvc 3,Partial Views,Mi的麻烦在于:我有一个叫做“创建”的视图,它指的是创建促销活动。每个促销都有用户的类型,因此,当我进入“创建促销”时,我有一个包含用户类型的列表(下拉列表),但如果没有专业类型,我必须在不离开当前页面的情况下创建它,因此我使用部分视图创建新类型,并将其插入主视图(创建促销)它确实有效,但在创建类型之后,主视图将显示所有类型,而不仅仅是与当前用户对应的类型 这是主要观点: @model Points2Pay.Models.Promocion @{ ViewBag.Title = "Cr
@model Points2Pay.Models.Promocion
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<script type="text/javascript">
$(document).ready(function () {
$(".slidingDiv").hide();
$(".show_hide").show();
$('.show_hide').click(function () {
$(".slidingDiv").slideToggle();
});
});
希望您能帮助我。您能给我们展示一下您的创作活动吗?谢谢,我已经采取了另一种方式
@using (Html.BeginForm())
{
<a href="#" class="show_hide">Show/hide</a>
<div class="slidingDiv" id="partialView">
@{Html.RenderAction("Create2", "Genre");}
</div>
}
@using (Html.BeginForm("Create","StoreManager"))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Promocion</legend>
<div class="editor-label">
@Html.LabelFor(model => model.GenreId, "Genre")
</div>
<div class="editor-field" id="DROPDOWN">
@Html.DropDownList("GenreId", String.Empty)
@Html.ValidationMessageFor(model => model.GenreId)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Title)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Title)
@Html.ValidationMessageFor(model => model.Title)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Price)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Price)
@Html.ValidationMessageFor(model => model.Price)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Puntos)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Puntos)
@Html.ValidationMessageFor(model => model.Puntos)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.PromocionArtUrl)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.PromocionArtUrl)
@Html.ValidationMessageFor(model => model.PromocionArtUrl)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>`
@model Points2Pay.Models.Genre
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<legend>New Genre</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Description)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
</div>
<p>
<input type="submit" value="Create new Genre" />
</p>
}
[ChildActionOnly]
public ActionResult Create2()
{
return PartialView("Create2");
}
//
// POST: /Genre/Create2
[HttpPost]
public ActionResult Create2(Genre genre)
{
var ComercioActual = (Guid)System.Web.Security.Membership.GetUser().ProviderUserKey;
if (ModelState.IsValid)
{
genre.ComercioId = ComercioActual;
db.Genres.Add(genre);
db.SaveChanges();
return PartialView("Create2");
}
return PartialView("Create2");
}