tags:

views:

90

answers:

1

I work on Asp.Net VS08 C#. i create a web control .How to use JQuery Datepicker on webcontrol.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="wcCalendar.ascx.cs" Inherits="Jquery1._8Version.wcCalendar" %>

 <link type="text/css" href="css/ui-lightness/jquery-ui-1.8rc2.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8rc2.custom.min.js"></script>

     <script type="text/javascript">
        $(function() {
        $("#dtpCalendar").datepicker();
        });
    </script>



    <div>
        <asp:TextBox ID="dtpCalendar" runat="server"></asp:TextBox>     
    </div>

I want to use this control on .aspx page ,

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JGrid.aspx.cs" Inherits="Jquery1._8Version.JGrid" %>

<%@ Register src="wcCalendar.ascx" tagname="wcCalendar" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>

</head>
<body>
    <form id="form1" runat="server">
    <div>

        <uc1:wcCalendar ID="wcCalendar1" runat="server" />

    </div>
    </form>
</body>
</html>

Clicking on textbox Datepicker not show? how to solve it?

+2  A: 

The problem is that the id of the textbox isn't "dtpCalendar" when its rendered to the client. You can do something like this to solve the issue:

$("#<%=dtpCalendar.ClientID%>").datepicker();
Mattias Jakobsson
Thanks. please tell me how I can use a jquery datepicker control in a GridView on edit mode?
Then I would probably set a css class on the textbox and use that instead of the id. Something like this: $(".datepicker").datepicker();
Mattias Jakobsson
please show me some syntax.Here is the textbox of my editable gridview<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("BirthDate") %>' CssClass="datepicker"></asp:TextBox>
If you have that code you should just need to add the line I wrote in my last comment, $(".datepicker").datepicker(); and you should be good to go.
Mattias Jakobsson