mam problemu przekształca się w ASP.NET-MVC Helper mam postać, która daje POST do działania ** tworzyć regulatora Występowanie przechodzącą parametr typu występowania że odpowiadający na modelu z widzenia którym umieszczana jest forma, dla zarejestrowania wystąpienie potrzebny jest TypeOccurrenceID, staram się dostać tę wartość za pomocą Html.DropDownListFor (), ale to nie jest pracy, gdy formularz jest wysyłany The Występowanie przeszłość w parametrze nie mają OccurrenceTypeId odpowiadające wybranym w DropDownListKendo DropDownListFor() z ASP.NET-MVC
Ktoś OccurrenceType miał ten sam problem?
To jest moje działania kontrolera
[HttpPost]
public ActionResult Create(Occurrence occurrence)
{
if (ModelState.IsValid)
{
try
{
db.Add<Occurrence>(occurrence);
return new HttpStatusCodeResult(200);
}
catch (Exception)
{
return new HttpStatusCodeResult(400);
}
}
return new HttpStatusCodeResult(400);
}
Oto moim zdaniem
@using Common.Util
@using Common.Util.Configuration
@using CafData
@model Occurrence
<div class="box-form">
@using (Ajax.BeginForm("Create", "Occurrence",
new AjaxOptions
{
OnSuccess = "OnSuccess()",
OnFailure = "OnFailure()"
}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@*Area*@
<div class="row-fluid details-field">
@(Html.Kendo().DropDownList()
.Name("areas")
.HtmlAttributes(new { style = "width:300px" })
.OptionLabel("Selecione uma area...")
.DataTextField("Description")
.DataValueField("IdArea")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("readAreasForDropDown", "Area");
});
})
)
@*Occurrence type*@
@(Html.Kendo().DropDownListFor(m => m.OccurrenceTypeId)
.Name("occurrencetype")
.HtmlAttributes(new { style = "width:300px" })
.OptionLabel("Select a occurrence type...")
.DataTextField("Description")
.DataValueField("OccurrenceTypeId")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("lerOccurrenceTypeForDropDown",
"OccurrenceType").Data("filterArea").
Type(HttpVerbs.Post);
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("areas")
)
<script>
function filterArea() {
return {
id: $("#areas").val()
};
}
</script>
<button class="k-button">Save</button>
}
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Przepraszamy za zły język angielski!
rozwiązany, ale mogę tylko pisać odpowiedź po 8 godzinach z powodu reputacji –
Proszę zaktualizować odpowiedź –