hi possible send parameters view controller without using ajax?
my view
@html.labelfor(model => model.fromdate) @html.textboxfor(model => model.fromdate, new { @class = "form-control", type = "text" }) @html.labelfor(model => model.todate) @html.textboxfor(model => model.todate, new { @class = "form-control", type = "text" }) <input id="button1" type="button" value="ok" />
my controller
public actionresult getdates(string fromdate, string todate) { datetime fromdt = convert.todatetime(fromdate); datetime todt = convert.todatetime(todate); sqlconnection con = new sqlconnection(@"data source=192.168.0.73\sqlexpress,14330;initial catalog=wafeerp_new;user id=sa;password=wafewin;"); datatable dt = new datatable(); try { con.open(); sqlcommand cmd = new sqlcommand("select * view_visitorsform visitingdate >='" + fromdt +"'and visitingdate <= '" + todt +"'", con); sqldataadapter adp = new sqldataadapter(cmd); adp.fill(dt); } catch (exception ex) { throw; } reportclass rc = new reportclass(); rc.filename = server.mappath("/reports/rpt_dailycustomervisitsummary.rpt"); rc.load(); rc.setdatasource(dt); stream stream = rc.exporttostream(crystaldecisions.shared.exportformattype.portabledocformat); return file(stream, "application/pdf"); }
hi have 2 fields in view if select date , date , click ok button needs pass these 2 dates controller here
public actionresult getdates(string fromdate, string todate )
is possible? using ajax possible don't want that. want pass these parameters controller without using ajax. please 1 tell me solution.
advance thanks..
setting form should able pass parameters controller.
@using(html.beginform()){ @html.labelfor(model => model.fromdate) @html.textboxfor(model => model.fromdate, new { @class = "form-control", type = "text" }) @html.labelfor(model => model.todate) @html.textboxfor(model => model.todate, new { @class = "form-control", type = "text" }) <input id="button1" type="button" value="ok" /> }
also since appears using model can pass model controller instead. making sure set [httppost] data annotation signify posting data to.
[httppost] public actionresult getdates(yourmodel yourmodel) { var = yourmodel.fromdate; var = yourmodel.todate; }
Comments
Post a Comment