asp.net mvc - passing user input in url -
asp.net mvc - passing user input in url -
i need pass user inputs url. coursecontroller action is:
public actionresult parameter(datetime start, datetime end) { //some operations homecoming view(); }
i start , end time user in view. want see url this: course/parameter/start=userinput && end=userinput help appreciated.
my model is: public class machinesql{ public list<machines> sqlaccessparameter(datetime startdate, datetime enddate) { sqlconnection myconnection = new sqlconnection(connstr); myconnection.open(); sqlcommand mycommand = new sqlcommand("daterange",myconnection); mycommand.commandtype = commandtype.storedprocedure; mycommand.parameters.add("@sp_startdate", sqldbtype.datetime).value = startdate; mycommand.parameters.add("@sp_enddate", sqldbtype.datetime).value = enddate; sqldataadapter dataadapter = new sqldataadapter(); mycommand.executenonquery(); dataadapter.selectcommand = mycommand; dataset dset = new dataset(); dataadapter.fill(dset); myconnection.close(); list<machines> machinepost = new list<machines>(); foreach (datarow row in dset.tables[0].rows) { machines mac = new machines(); mac.autokey = (int)row["autokey"]; mac.machinegroup = (string)row["machinegroup"]; mac.duration = (int)row["duration"]; mac.startdate = (datetime)row["starttime"]; mac.enddate = (datetime)row["endtime"]; machinepost.add(mac); } homecoming machinepost; }}
since you're using ajax helper it's easy add together url parameters:
@using(ajax.beginform('parameter', 'course', //here how add together url params new { start = @model.startdate, end = @model.enddate } // ajax actions needed such hyypmethod, // onsuccess, etc... new ajaxoptions { //options here }, ))
this give url looks like:
course/parameter?start=userinput&end=userinput
asp.net-mvc
Comments
Post a Comment