views:

24

answers:

2

How do I make the jQuery Datepicker open up by a user defined button?

+4  A: 

There's built-in support for this, having an icon or button to right right of the textbox, like this:

$("#datepicker").datepicker({
  showOn: 'button',
  buttonImage: 'images/calendar.gif',
  buttonImageOnly: true
});

If you want to show it from another button, or really any event, call the show method, like this:

$("#myButton").click(function() {
  $("#datepicker").datepicker("show");
});

You can try it here

Nick Craver
Thanx bro..!! let me try anyways..
pvaju896
is there any problem wen i use the same with ASP.NET user-controls. ???
pvaju896
@pvaju896 - Nope...how are you calling it? Keep in mind that in a user control the ID will be different, you should use classes instead
Nick Craver
you meant JQUERY classes..?? am new to JQUERY..how can i set class so..?/?? i made user control with just a textbox registered to aspx page and called the usercontrol..i tried giving datepicker for that usercontrol textbox --> it dint wrk dats y..??wat should i do now..?/ how to do with classes??
pvaju896
+2  A: 

The samples page as an example of how to make the datpicker appear by clicking an icon:

http://jqueryui.com/demos/datepicker/#icon-trigger

smack0007