Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery date picker not working in asp.net web form

Following date picker is not work in asp.net web form. I changed code so many time not even other example are working & even create new page to test still not working.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type = "text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type = "text/javascript"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel = "Stylesheet" type="text/css" /> 
    <script type="text/javascript">

//Code Starts
$(document).ready(function() {

     $('#Text1').datepicker();
      $('#<%=txtBookDate.ClientID %>').datepicker();
});​

</script>
</head>

<body>
    <form id="form1" runat="server">
    <div>
     <asp:TextBox ID="txtBookDate" runat="server"></asp:TextBox><input id="Text1" type="text" />
    </div>
    </form>
</body>
</html>

Example on jsFiddler is working

http://jsfiddle.net/ANdUK/3/

like image 450
Learning Avatar asked Nov 13 '22 04:11

Learning


1 Answers

The problem is probably that the ids are changed somehow because they are inside a form. You should check the generated id and use it. BTW the example on jsfiddle doesn't work without jQuery UI

EDIT try not to put spaces in the script tag and try taking the normal input outside the form

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
like image 105
Nicola Peluchetti Avatar answered Dec 27 '22 08:12

Nicola Peluchetti