MVC 4 View reload with change in data
**I have a simple controller and view.
I just want the Index.cshtml view page to be reloaded with new data.I have
debugged the code thoroughly. Infact, clicking on the "ul" when the
control goes to the Index(string value) method the model object is
populated with new data and even in the cshtml page the Model is showing
the new list in the debugger, but the view is NOT getting refreshed. I
really don't know why.. Can anyone help me plz? If I have gone wrong
horribly somewhere plz excuse my ignorance as I am new to MVC. Thanks in
advance... Controller:**
namespace MVCTestApp1.Controllers
{
public class TestController : Controller
{
//
// GET: /Test/
public ActionResult Index()
{
ModelState.Clear();
List<string> ll = new List<string>();
ll.Add("qq");
ll.Add("aa");
ll.Add("zz");
return View(ll);
}
[HttpPost]
public ActionResult Index(string value)
{
ModelState.Clear();
List<string> ll = new List<string>();
ll.Add("kkk");
ll.Add("qq");
ll.Add("aa");
ll.Add("zz");
return View(ll);
}
}
}
View:
@model IEnumerable<string>
@{
ViewBag.Title = "Index";
}
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<h2>Index</h2>
<ul id="bb">
@foreach (var i in Model)
{
<li>@Html.DisplayFor(ir=>i)</li>
}
</ul>
}
No comments:
Post a Comment