0

im trying to use jquery from online to generate my datepicker. in my markup it is:

<asp:TextBox ID="PStart" runat="server"></asp:TextBox> 

followed by

<script type = "text/javascript">
    $(function () {
        $("#PStart").datepicker({
            showOn: "button",
            buttonImage: "images/calendar.gif",
            buttonImageOnly: true
        });
    });
</script>

and in my header of my site master i have included:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script type ="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type ="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />

one point to note is that this date picker is nested within an update panel which is only suposed to update after completeing the form and the submit/save button is clicked. i have set shildren as triggers to false and update mode to conditional but its not being displayed, far less for making a choice.

4

1 回答 1

1

如果没有看到更多的代码,就不可能肯定地说。但是,假设没有错误,问题可能在于<asp:ContentPlaceHolder>&<asp:Content>被调用。

使用占位符时,asp 控件将其 ID 更改为以下格式:{ContentPlaceHolderID}_ElementID.

我建议:

  • 更改<asp:TextBox ID="PStart" runat="server"></asp:TextBox><input id="PStart" type="text"/>

  • 检查页面并找到该元素的实际 id(很可能"#{ContentPlaceHolderID}_PStart")。

希望这会有所帮助,如果您有任何问题,请告诉我!


Site.Master:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebApplication1.SiteMaster" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script type ="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type ="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <asp:ContentPlaceHolder runat="server" ID="HeadContent" />
</head>
<body>
    <form runat="server">
        <div id="body">
            <asp:ContentPlaceHolder runat="server" ID="MainContent" />
        </div>
    </form>
</body>
</html>

默认.aspx:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<asp:Content runat="server" ContentPlaceHolderID="HeadContent">
    <script type = "text/javascript">
        $(function () {
            $("#MainContent_PStart, #PStart").datepicker({
                showOn: "button",
                buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
                buttonImageOnly: true
            });
        });
    </script>
</asp:Content>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <asp:TextBox ID="PStart" runat="server"></asp:TextBox> 
    <input type="text" id="PStart"/>
</asp:Content>

结果:

在此处输入图像描述

于 2013-11-14T18:43:26.320 回答