Passing Query String Values to a View Model in Asp.net MVC App -
how can pass query string values view model parameter has default values in asp.net mvc app?
i tried didn't succeed;
public actionresult index(myanothervm filter){ // filter.p doesn't set passed value , equals 1 } public class myanothervm { public int p { { return 1; } set { } } // or public int p=1; }
you can make use of tempdata
[httppost] public actionresult fillstudent(student student1) { tempdata["student"]= new student(); return redirecttoaction("getstudent","student"); } [httpget] public actionresult getstudent(student passedstd) { student std=(student)tempdata["student"]; return view(); }
approach 2:
using query string data passed
or can frame of query strings like
return redirecttoaction("getstudent","student", new {name="john", class="clsz"});
this generate request like
student/getstudent?name=john & class=clsz
but make sure have [httpget] since redirecttoaction issue request(302)
Comments
Post a Comment