Hi ist es möglich, Parameter von der Ansicht zum Controller zu senden, ohne Ajax zu verwenden?Wie kann man Parameter von View zu Controller übertragen, ohne Ajax in MVC4 zu verwenden?
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" />
Mein 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 * from View_VisitorsForm where 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");
}
Hallo ich habe zwei Felder aus meiner Sicht, wenn ich das Von-Datum und bis Datum und klicken Sie auf die OK-Taste, es muss wählen um diese beiden Daten an den Controller zu übergeben, der hier ist
public ActionResult GetDates(string FromDate, string ToDate)
Ist es möglich? Mit Ajax ist es möglich, aber ich will das nicht. Ich möchte diese Parameter an den Controller übergeben, ohne Ajax zu verwenden. bitte irgendjemand sagt mir die Lösung.
Voraus Dank ..
'@ Html.BeginForm() {// Ihr hier View-Code}'? – Izzy
dann was ich tun muss lzzy den Wert an den Controller übergeben – Susan