Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i have used Jquery Calendare which works well. for that i have used
"jquery-ui.min.js" and "jquery-ui.css" Library File.

i can show the calender, show the current date. Also i can highlight the task set dates.

But what i cant do is, when user click on any date, i cant get the event. i want the user to redirect to another page with selected date. but i am not able to get event on the date.

The vierd thing is, on blank area of calendar i get the event, and also i can get the selected date value, but when user clicks on date, that time i dont get any event.

I have attached code for your reference. Any idea to solve the issue?


XML
Site Master Page

-----------------------------------

<script type="text/javascript" src="../../Scripts/jquery-ui.min.js"></script>

<link href="../../Content/jquery-ui.css" rel="stylesheet" type="text/css" />



Calendar Page

------------------------------------------------------------------------------------

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

ShowCalendar

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>ShowCalendar</h2>

<script type="text/javascript">

$(function () {

var someDates = ['10/8/2011', '10/28/2011', '10/30/2011', '11/7/2011', '12/7/2011'];

$("#testDateDiv").datepicker({

beforeShowDay: function (date) {

for (var i = 0; i < someDates.length; i++) {

if (new Date(someDates[i]).toString() == date.toString()) {

return [true, 'someDates'];

}

}

return [true];

}

});

});

$(function () {

debugger;

if ($("#testDateDiv").click(function () {

var obj1 = $('#testDateDiv').val();

$('#' + $('#DateDiv').val()).datepicker('setDate', obj1);

alert(obj1);

// window.location = "http://localhost:4300/Home/Account?strDate=" + obj1;

}));

});

</script>

<div id="testDateDiv" style="width: 300px">

</div>

</asp:Content>
Posted

1 solution

Hi,

jQuery UI Calendar provides an event "onSelect" which is gets called when you select the date. You need to use this method to fulfill your purpose.

C#
$(function()
{
    $('#txtDate').datepicker({ onSelect:
      function(dt)
      {
          window.open("http://www.google.com?dt=" + dt);
      }
   });
});


You can see the demo at http://jsfiddle.net/jquerybyexample/xd6W5/[^]

Also, do read this series of articles related with jQuery and jQuery Datepicker. They are really helpful.
http://jquerybyexample.blogspot.com/search/label/jQuery%20DatePicker[^]

Hope this help.

Thanks,
Virendra
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900