VS2010'da (MVC 4) Razor kullanarak bir C# projesi yapıyorum. Denetleyiciden Görüntülenecek ve Kullanıcıya gösterilecek hata iletisini döndürmem gerekiyor. Ne denedim idi:MVC 4-Denetleyici'den gelen hata iletisini göster - Göster in Görünüm
KONTROL:
[HttpPost]
public ActionResult form_edit(FormModels model)
{
model.error_msg = model.update_content(model);
ModelState.AddModelError("error", "adfdghdghgdhgdhdgda");
ViewBag.error = TempData["error"];
return RedirectToAction("Form_edit", "Form");
}
GÖRÜNÜM:
@model mvc_cs.Models.FormModels
@using ctrlr = mvc_cs.Controllers.FormController
@using (Html.BeginForm("form_edit", "Form", FormMethod.Post))
{
<table>
<tr>
<td>
@Html.ValidationSummary("error")
@Html.ValidationMessage("error")
</td>
</tr>
<tr>
<th>
@Html.DisplayNameFor(model => model.content_name)
@Html.DropDownListFor(x => x.selectedvalue, new SelectList(Model.Countries, Model.dd_value, Model.dd_text), "-- Select Product--")
</th>
</tr>
</table>
<table>
<tr>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</table>
}
bunu başarmak için bana yardım edin.
Eminseniz yönlendirmesi döndürmesine istiyor ve görüntüleyemezsiniz? – Grundy
'Return' ('Form') yerine 'Return' ('Form') 'i döndürmek yerine View (model)' i döndürün; ' – Grundy
Ya, RedirectToAction (" Form_edit "," Form ") iadesine ihtiyacım var; – Ramesh