How to pass data partialview

Posted by Jayakumars under ASP.NET MVC on 1/24/2014 | Points: 10 | Views : 1742 | Status : [Member] [MVP] | Replies : 1
Hi
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

Kumaraspcode2009@gmail.com



Responses

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

Up
0
Down
Hi,

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"%>

<h2>Categories</h2>

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

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

<% } %>


Please Mark as answer if this is useful

Thank you,
Govind

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

Login to post response