Articles → ASP .NET MVC → Passing Parameter In Partial Views In Asp.Net Mvc
Passing Parameter In Partial Views In Asp.Net Mvc
Sample Project
Click to Enlarge
Adding Partial View
Click to Enlarge
@Html.Partial("_PartialView")
Passing Parameters In Partial View
@{
ViewBag.Title = "Home Page";
string option = "search";
}
@Html.Partial("_PartialView", option)
<table>
@if (@Model == "search")
{
<tr><td><a href="http://google.com" target="_blank">Google</a></td></tr><tr><td><a href="http://bing.com" target="_blank">Bing</a></td></tr>
}
else
{
<tr><td><a href="mail.yahoo.com" target="_blank">Yahoo mail</a></td></tr>
}
</table>
Click to Enlarge
Click to Enlarge