Hi is it possible to send parameters from view to 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 * 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");
}
Hi i have two fields in my view if i select the From Date and To Date and click the ok button it needs to pass these two dates to controller that is here
public ActionResult GetDates(string FromDate, string ToDate )
Is it possible? Using ajax it is possible but i don't want that. I want to pass these parameters to controller without using ajax. please any one tell me the solution.
Advance thanks..
@Html.BeginForm(){ //your view code here}?