3
Answers

How to call action method using ajax in mvc5

dear all,
 
 
how to call the Action method from the side menu item click using ajax...???
 
my controller is
 
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}

public ActionResult About()
{
ViewBag.Message = "Your application description page.";

return View();
}

public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";

return View();
}
 
and site menu on layout is
 
  • Dashboard

  • Database

  • Amma Zaan
  •  
     
    once we click on any link it should open the respective view in renderbody() without postback.
    Answers (3)
    1
    Nitin Sontakke

    Nitin Sontakke

    NA 11.7k 2.2k 8y
    How is it different is not clear to me. Can you please explain?
     
    In fact, you already seem to have done it. So where is the problem?
     
    You should also elaborate on "not working". Did you debug? In _DayRender event, is date variable getting correct value?
     
    Accepted
    0
    Hold On

    Hold On

    NA 390 13.8k 8y
    @Gnanavel Sekar , Thanks for your reply. I will also try this one.
    0
    Gnanavel Sekar

    Gnanavel Sekar

    NA 6.8k 452.1k 8y
    Just set the minimum value for second calender once the date picked from first calender , for this you may use client side jquery to overcome this.
     example in click event
    var arr = selectedDate.split("/");
    var date = new Date(arr[2]+"-"+arr[1]+"-"+arr[0]);
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
    var minDate = new Date(y, m, d + 1);
    $("#EndDate").datepicker('setDate', minDate);
     
     
    Refer below links
     
    http://stackoverflow.com/questions/27721133/jquery-datepickers-setting-end-date-from-a-start-date
    http://stackoverflow.com/questions/24894048/jquery-datepicker-how-to-set-start-and-end-date
    http://stackoverflow.com/questions/17016598/jquery-ui-picking-a-start-and-end-date-within-range-based-on-start-date 
    http://www.aspsnippets.com/Articles/jQuery-DatePicker-Start-Date-should-be-less-than-End-date-validation.aspx 
     
    0
    Hold On

    Hold On

    NA 390 13.8k 8y
    @Nitin Sontakke
     
    Thank you for pointing my mistake. I got it now. The problem is the ">", I changed it to "<" and now it worked!.
    1. protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)  
    2.         {  
    3.             DateTime date = Convert.ToDateTime(TextBox1.Text);   
    4.   
    5.             if (e.Day.Date < date)  
    6.             {  
    7.                 e.Cell.Enabled = false;  
    8.                 e.Day.IsSelectable = false;  
    9.             }  
    10.         }  
     
    0
    Hold On

    Hold On

    NA 390 13.8k 8y
    @Nitin Sontakke
     
    Yes I have seen it but it's a different scenario.  
    0
    Nitin Sontakke

    Nitin Sontakke

    NA 11.7k 2.2k 8y
    Have you had a look at this?
     
    http://stackoverflow.com/questions/10227417/setting-minimum-and-maximum-date-on-calendar