How to do an 'include' or user control (ascx) in MVC, and pass data or model to it


How to do an 'include' in MVC, and pass data to it.


in aspx


<%Html.RenderAction<LifeInsuranceController>(controller=>controller.PopHealthRespiratory(record)); %>


in controller. Note: record is the typed data you are passing to the ascx view


public ActionResult PopHealthRespiratory(Policy record)


     return View("PopHealthRespiratory",record);



in new view named PopHealthRespiratory.ascx


<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Models.Policy>" %>

<%var record = Model; %>

<div class="modalMessage" style="width: 470px;">

<table border="0" cellpadding="0" cellspacing="0" width="100%" style="width: 470px;">


<td valign="top">

<%=new Forms.TextField(record.Fields.FirstName, true) %>









Leave a Comment