none
jQuery DatePicker throw error in SharePoint 2007 RRS feed

  • Question

  • Hi All,

    I trying to use jquery datepicker plug in a User Control, then User Control is deploy into SharePoint 2007 UserControls folder in VirtualDirectories.

    but I hit javascript error saying that object expected.

    I had added the required js file (jQuery & jQuery ui) into master page, and the script was as below:

     

     

    <script>

        $(document).ready(function() {

            $("#tbDateOfPurchase").datepicker();

        });

    </script>

     

    <input id="tbDateOfPurchase" type="text" />

     

    Please help, thank you in advanced.

     

    Monday, April 25, 2011 9:51 AM

Answers

  • Alireza,

    Thank for your reply,

    I have solved it anyway, it is because of my jQuery Selector problem.

    $("#tbDateOfPurchase").datepicker(); will not work in SharePoint environment in my situation,

    the TextBox control will be render as ct100_<ContentPlaceHolderID>_<UserControlID>_<TextBoxControlID>

    Therefore, a better way of select the TextBox ID is $("#<%=tbDateOfPurchase.ClientID %>").datepicker();

    Thanks

    • Marked as answer by sams371 Wednesday, May 4, 2011 3:49 PM
    Tuesday, April 26, 2011 2:10 AM

All replies

  • Did you add jquery.min.js to your user control file ?

    if not use this code (add head of html)

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

    Monday, April 25, 2011 3:56 PM
  • Alireza,

    Thank for your reply,

    I have solved it anyway, it is because of my jQuery Selector problem.

    $("#tbDateOfPurchase").datepicker(); will not work in SharePoint environment in my situation,

    the TextBox control will be render as ct100_<ContentPlaceHolderID>_<UserControlID>_<TextBoxControlID>

    Therefore, a better way of select the TextBox ID is $("#<%=tbDateOfPurchase.ClientID %>").datepicker();

    Thanks

    • Marked as answer by sams371 Wednesday, May 4, 2011 3:49 PM
    Tuesday, April 26, 2011 2:10 AM