사용자 입력을 URL에 전달해야합니다. 내 CourseController 조치는 다음과 같습니다 사용자 입력을 URL에 전달하십시오.
public ActionResult Parameter(DateTime start, DateTime end)
{
//some operations
return View();
}
나는 내보기에 사용자로부터 시작 시간과 종료 시간을 얻을. 다음과 같은 URL을보고 싶습니다. Course/Parameter/start = userinput & & end = userinput 어떤 도움을 주시면 감사하겠습니다.
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);
}
return machinePost;
}}
"내보기에서 사용자의 시작과 끝"이라고 말하면 양식을 사용하여 제출 한 것입니까? – tomasmcguinness
@tomasmcguinness 예, @using (ajax.beginform ('ActionName', 'ControllerName')) – pln
URL을 통해 값을 전달 하시겠습니까? – tomasmcguinness