controller - Multiple partial views on one main asp.net -


trying put typed partial view on homepage in asp.net wont seem work it, here code

new asp.net , partial views.

controller :

    public actionresult venuepartial()     {         viewdata["message"] = _entities.venuepartiallist();         return view();     } 

repository :

    public ienumerable<venue> venuepartiallist()     {         var list = s in _entities.venue                    orderby s.name ascending                    select s;         return list.tolist();     } 

irepository :

    ienumerable<venue> venuepartiallist(); 

index page :

   <%html.renderpartial("~/views/venue/venuepartial.ascx");%> 

any grateful asap please regards t

maybe need pass model partial:

<% html.renderpartial("~/views/venue/venuepartial.ascx", viewdata["message"]); %> 

and way wtf using viewdata["message"] pass model instead of using model , typed view:

public actionresult venuepartial() {     return view(_entities.venuepartiallist()); } 

and then:

<% html.renderpartial("~/views/venue/venuepartial.ascx", model); %> 

this assumes partial typed ienumerable<venue>. if typed single venue might consider using editor/display templates. in main view:

<%= html.displayformodel() %> 

and in corresponding display template (~/views/shared/displaytemplates/venue.ascx):

<%@ control      language="c#"      inherits="system.web.mvc.viewusercontrol<appname.models.venue>" %> <span>     <%= html.displayfor(x => x.somepropertyofvenue) %> </span> 

and display template rendered each item of model collection.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -