简体   繁体   中英

ASP.NET & jQuery Calendar - Does not Work

I've got a test page put together to display a jQuery Calendar.

It seems like I have created everything correctly, but the Calendar control does not show.

Does anyone see anything wrong with my example below?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestjQuery.aspx.cs" Inherits="AcpSheetMetal.TestjQuery" %>
<!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>jQuery Calendar Test</title>
  <link rel="Stylesheet" type="text/css" href="Styles/jquery.ui.datepicker.css" />
  <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript" />
  <script src="Scripts/jquery.ui.datepicker.js" type="text/javascript" />
  <script type="text/javascript">
    $(function () {
      alert("Select Dates and Run Search.");
      $("#txtStartDate").datepicker();
      $("#txtEndDate").datepicker();
    });
  </script>
</head>
<body>
  <form id="form1" runat="server">
  <div>
  <table style="height:100%;width:100%">
    <tr>
      <td style="width:20%;">
        <asp:Label ID="lblStartDate" runat="server" Text="[Start Date]" /><br />
        <asp:TextBox ID="txtStartDate" runat="server" ClientIDMode="Static"></asp:TextBox>
      </td>
      <td style="width:20%;">
        <asp:Label ID="lblEndDate" runat="server" Text="[End Date]" /><br />
        <asp:TextBox ID="txtEndDate" runat="server" ClientIDMode="Static"></asp:TextBox>
      </td>
      <td style="text-align:left;">
        Run Search:<br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
      </td>
    </tr>
  </table>
  </div>
  </form>
</body>
</html>

It's probably the self closing script tags causing the problem -

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript" />

try using this pattern instead for all the script tags

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

See this question for further info - Why don't self-closing script tags work?

Because you said the alert does not fire I would say that the path Scripts/jquery-1.4.1.min.js could be wrong.

Are you sure this points to your javascript file?

Make sure your paths are correct and close your JavaScript tags:

  <link rel="Stylesheet" type="text/css" href='<%= Page.UrlResolve("~/Styles/jquery.ui.datepicker.css" %>' />
  <script src='<%= Page.UrlResolve("~/Scripts/jquery-1.4.1.min.js" %>'  type="text/javascript"></script>
  <script src='<%= Page.UrlResolve("~/Scripts/jquery.ui.datepicker.js" %>'  type="text/javascript"></script>

Why don't self-closing script tags work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM