asp.net mvc 4 - Passing a string (besides the model) into a partial view in MVC4 -


how can send string partial view?

what send information model being viewed, partial view. this:

@{html.renderpartial("_phasecreate", new phase(), @model.id );} 

is possible?

if want send data isn't in model or view, should use following:

1) instead of @html.partial(), use @html.action("actionname", "controller", routevalues: new { id = model.id }) helper.

2) add controller:

public actionresult getmyview(int id) {     viewbag.phase = new phase();     viewbag.id = id;     // whatever doesn't in model ...      return view("_phasecreate"); } 

and in partial view, can use info declare them:

<label>@viewbag.id</label> 

you can use following if need add data existing in model , view:

@html.partial("_phasecreate",                new viewdatadictionary(new { phase = new phase(), id = model.id })) 

and use them this:

<label>@viewdata["id"].tostring()</label> 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -