Trying to pass Model down to partial, how do I do this?
- by mrblah
My action creates a strongly typed viewdata, which is passed to my view.
In the view, I pass the Model to the render partial method.
public ActionResult Index()
{
ViewDataForIndex vd = new ViewDataForIndex();
vd.Users = Users.GetAll();
return View(vd);
}
public class ViewDataForIndex: ViewData
{
public IList<User> Users {get;set;}
}
now in the view:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ViewDataForIndex>" %>
<% Html.RenderPartial("~/controls/blah.ascx", ViewData.Model); %>
and in blah.ascx:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
how do I access my model now?
if I wanted to create a strongly typed class for my ViewUserControl, how would I do that? inherit from?