Hi..
I am new to MVC 4.
I am developing a simple application in MVC 4 using Razor in c#.
Now i need to Display a error in view which is pass from controller?
How can i achieve it?
MY CODES:
MY VIEW CODE:
-------------
@model mvc_cs.Models.FormModels
@using ctrlr = mvc_cs.Controllers.FormController
@{
ViewBag.Title = "form_edit";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>
form_edit</h2>
@using (Html.BeginForm("form_edit", "Form", FormMethod.Post))
{
<table>
<tr>
<td>
@Html.DisplayTextFor(model => model.error_msg)
@Html.ValidationSummary(false)
</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>
}
MY CONTROLLER:
--------------
[HttpPost]
public ActionResult form_edit(FormModels model)
{
model.error_msg = model.update_content(model);
TempData["error"] = "fjghsfhgflsh";
ModelState.AddModelError("error.error", "adfdghdghgdhgdhdgda");
return RedirectToAction("Form_edit", "Form",model.error_msg);
}