So many times , developer face the issues , how to replace asp.net User Control , with MVC , So simples solution use Partial View.
Step 1: Make Action inside of Controller
Example
Step 1: Make Action inside of Controller
Example
[ChildActionOnly]
public ActionResult CourseCategory()
{
var genres = db.CourseCategorys.ToList();
return PartialView(genres);
}
Step 2: Partial View Source code
Step 2: Partial View Source code
@model IEnumerable<MVC4EF5_DEMO.Models.CourseCategory>
<ul id="categories">
@foreach (var CategoryID in Model)
{
<li>@Html.ActionLink(CategoryID.Name,
"Browse", "Predict",
new { CategoryID = CategoryID.CourseCategoryID }, null)
</li>
}
</ul>
Step 3: How to call according to your need.
@{Html.RenderAction("CourseCategory", "CourseCategory");}
Anywhere you call according to ur requirement.
Plz If this code is useful for anybody plz send your valuable comment.
Step 3: How to call according to your need.
@{Html.RenderAction("CourseCategory", "CourseCategory");}
Anywhere you call according to ur requirement.
Plz If this code is useful for anybody plz send your valuable comment.
Source collected from CSharpCorner.com
http://www.c-sharpcorner.com/Blogs/12837/how-to-use-partial-view-in-mvc3-and-mvc4-with-examples.aspx
http://www.c-sharpcorner.com/Blogs/12837/how-to-use-partial-view-in-mvc3-and-mvc4-with-examples.aspx
No comments:
Post a Comment