2011-09-08 28 views
0

jQuery的日期選擇器是不是在用戶控件通過母版工作....掙扎了很多工作.....Jquery的日期時間選擇器不能與母版

母版

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> 
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> 
    <!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>Master Page</title> 
    <link href="App_Themes/LMSTheme/Style.css" rel="stylesheet" type="text/css" /> 
    <link type="text/css" rel="stylesheet" href="../App_Themes/LMSTheme/jquery-ui-1.8.16.custom.css" /> 

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

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

    <script src="Scripts/ui.datepicker.js" type="text/javascript"></script> 

    <style>.Hide{ display:none;}</style> 
</head> 
<body> 
    <form id="form1" runat="server"> 
     <div class="divcontent"> 
      <table width="100%"> 
       <tr height="400px" valign="top"> 
        <td width="10px"> 
        </td> 
        <td> 
         <asp:ContentPlaceHolder ID="WorkArea" runat="server"> 
         </asp:ContentPlaceHolder> 
        </td> 
       </tr> 
      </table> 
     </div> 
    </form> 
</body> 
</html> 

這是我的用戶:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HRApproveSwipeLeave.ascx.cs" 
    Inherits="HRApproveSwipeLeave" %> 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> 
<link type="text/css" rel="stylesheet" href="../App_Themes/LMSTheme/jquery-ui-1.8.16.custom.css" /> 
<script type="text/javascript" src="../Scripts/jquery-1.6.2.min.js"></script> 
<script type="text/javascript" src="../Scripts/jquery-ui-1.8.16.custom.min.js"></script> 
<script src="../../Scripts/ui.datepicker.js" type="text/javascript"></script> 
<script language="javascript" type="text/javascript"> 
    $(document).ready(function() { 
     $('#txtDate').datepicker({changeMonth: true, 
      changeYear: true}); 
    }); 
</script> 

<div class="demo"> 
    <asp:TextBox ID="txtDate" runat="server"></asp:TextBox> 
</div> 

這是ASPX,而我叫thourgh母版頁.....

<%@ Page Language="C#" AutoEventWireup="true" Theme="LMSSkinFile" MasterPageFile="~/MasterPage.master" CodeFile="HRApprovSwipeLeave.aspx.cs" Inherits="HRApprovSwipeLeave" Title="ApproveSwipeLeave"%> 
<%@ Register Src="UserControl/HRApproveSwipeLeave.ascx" TagName="HRApproveSwipeLeave" TagPrefix="LMS" %> 
<asp:Content ID="LMS_HRApproveSwipeLeave" ContentPlaceHolderID="WorkArea" runat="Server"> 
    <asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional"> 
     <contenttemplate> 
    <table> 
     <tr> 
      <td class="BoldCopy"> 
       <asp:Label ID="WelcomeUserName" runat="server" Visible="false"></asp:Label>     
      </td> 
     </tr>  
    </table> 
    <table> 
     <tr> 
      <td>     
       <asp:Label ID="ApproveSwipeLeave" Font-Bold=true ForeColor=red runat="server"></asp:Label>  
      </td> 
     </tr> 
     <tr> 
      <td>     
       <LMS:HRApproveSwipeLeave ID="LMSHRApproveSwipeLeave" runat="server" /> 
      </td> 
     </tr> 
      </table> 
     </contenttemplate> 
    </asp:UpdatePanel> 
</asp:Content> 

注意:jquery時間選擇器,當我通過用戶控件運行時,它並不是在所有射擊..如果我創建一個示例aspx,並且它正在工作....我不會在哪裏更改代碼主頁或ascx或aspx..for你的參考我已發送three.please幫助解決...我正在挖這個很多.....

+0

你確認您的document.ready()獲取調用? –

+0

你的pblm是在調用jquery –

+0

你說的「如果我創建一個樣本aspx並且它正在工作」的母版頁。你能發佈「sample aspx」嗎? –

回答

0

以下代碼正在爲我工​​作。

母版頁

<head runat="server"> 
<%--JQUERY--%> 

<link rel = "Stylesheet" href ="../jquery-ui-1.8.13.custom/development-bundle/demos/demos.css" /> 
<link rel = "Stylesheet" href ="../jquery-ui-1.8.13.custom/development-bundle/themes/base/jquery.ui.all.css" /> 

<script language="javascript" src="script.js"> </script> 

<script src="../Scripts/jquery-1.6.1.js" type="text/javascript"></script> 
<script src="../Scripts/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script> 

<%--JQUERY--%> 

客戶端頁面

<asp:Content ID="Content1" ContentPlaceHolderID="maincontent" Runat="Server"> 
    <script type ="text/javascript"> 
     $(function() { 

      $("#<%= txtDate.ClientID %>").datepicker(); 

     }); 

    </script> 

     <div id ="divname"> 

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

     </div> 
    </asp:Content> 
0

它不工作的原因是因爲你的控制生成ID可能不是#txtDate。如果你想保持它,請將其ClientIDMode屬性設置爲Static。否則,使用不同的jquery選擇器。

+0

好心幫助我應該在哪裏更改代碼... –

+0

或編輯我的代碼請挖掘很多...在此 –

+0

我cahanged $('#txtDate')。datepicker,$(「#<%= txtFromDate.ClientID %>「)。datepicker,$('input [name = txtFromDate]')。datepicker .....但是沒有用.. –

相關問題