|
How to create a view where data is rendered from different action methods. or where the data comes from different action methods.
Eg. I am building a community portal. I have data from different areas like, News, Weather , Flight Information etc in the home page. If these data are
returned by differnt action methods how do I update them in HomeControllder Index.aspx.
Here U go the solution.
Lets Call HomeController the Parent and Index the parent view.
There are 3 Child Action Methods.
News
Weather
FlightInfo
Which returnds HTML Data.
These are the methods.
public ActionResult News()
{
return View("Hot News | ");
}
public ActionResult Weather()
{
return View("Chicago 10dc");
}
public ActionResult News()
{
return FlightInfo("Something Is going on in America");
}
<%= Html.Action("News") %>
or
<% Html.RenderAction("News"); %>
To render news. Can do same for others.
IF U WANT JUST ONE ACTION METHOD. AND RETURN RESPECTIVE HTML ON RECEIGING PARAMTER THIS IS WHAT U DO
public ActionResult Display(string section)
{
return View(section);
}
<% Html.RenderAction("News",new { section = "News" }); %>
| |