How to pass data partialview

Posted by Jayakumars under ASP.NET MVC on 1/24/2014 | Points: 10 | Views : 1551 | Status : [Member] [MVP] | Replies : 1
I am done mvc3 aspx page here i placed ascx file in my aspx page here
how to pass and show my data to ascx file in mvc3

Mark as Answer if its helpful to you


Posted by: kgovindarao523-21772 on: 1/24/2014 [Member] [MVP] Bronze | Points: 25


In Your aspx view, call partial view like this.
(note that you are using valid Model, Model is the data you want to pass to render partial view)
<% Html.RenderPartial("SharedPartial",Model); %>

Now in .ascx file:

The code and model is according to your model.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Category>>" %>
<%@ Import Namespace="MyMVCApplication.Models"%>
<%@ Import Namespace="Microsoft.Web.Mvc"%>


<% foreach (var category in Model)
{ %>

<li> <%= category.Name %> </li>

<% } %>

Please Mark as answer if this is useful

Thank you,

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response