Jquery date picker not working in asp.net web form

The following data collector does not work on the asp.net web form. I have changed the code so many times that even another example does not work, and even create a new page for verification, which does not work yet.

<%@ 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> 

JsFiddler working example

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

+4
source share
2 answers

After the last semi-colony in the following line of code:

 $(document).ready(function() { $('#Text1').datepicker(); $('#<%=txtBookDate.ClientID %>').datepicker(); });โ€‹ 

You have some dodgy character. Remove it and you will be fine.

0
source

The problem is probably the identifiers are somehow changed because they are inside the form. You must check the generated identifier and use it. By the way, jsfiddle example does not work without jQuery UI

EDIT try not to put spaces in the script tag and try to accept regular 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> 
+1
source

Source: https://habr.com/ru/post/1415131/


All Articles