简体   繁体   English

在DetailsView插入/编辑模板中使用JQuery datepicker()

[英]Using JQuery datepicker() in DetailsView insert/Edit templates

I am having a hard time getting the jquery datepicker to work with my DetailsView insert template. 我很难让jquery datepicker与我的DetailsView插入模板一起使用。 I have tried numorous ways of trying to get this to work and I have not been successful inside of the Template control. 我尝试了多种方法来使它起作用,但在Template控件内部却没有成功。 The code works fine outside of the DetailsView, but I need it inside. 该代码在DetailsView外部运行良好,但是我在内部需要它。 Here is my code: 这是我的代码:

<link href="jquery-ui-1.7.3.custom.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript" src"jquery-ui-1.7.3.custom.min.js"></script>
<script type="text/javascript" language="javascript" src"jquery-1.6.2.min.js"></script>

<script type="text/javascript" language="javascript">

function pageLoad(sender, args) 
    {
        $('.DateControl').datepicker();
    };
</script>

<asp:templatefield HeaderText="Action Date" SortExpression="Action_Date">
    <InsertItemTemplate>
        <asp:Textbox runat="server" Text='<%# Bind("Action_Date") %>' id="textAction" CssClass="DateControl">
        </asp:textBox>
    </InsertItemTemplate>

</script>

Any help on what I could possibly doing wrong would be helpful. 对我可能做错的任何帮助都会有所帮助。 oh, and I am working with SharePoint and I will not be able to use the Ajax Controls for a datepicker. 哦,而且我正在使用SharePoint,因此无法将Ajax控件用于日期选择器。

Have you used Firebug (or similar) to verify that your pageLoad() function is being called? 您是否使用过Firebug(或类似工具)来验证是否正在调用pageLoad()函数? For use with jQuery, I've found the following notation to be much more common, for code which must be executed just once, when the page loads: 对于与jQuery结合使用,我发现以下表示法更为常见,因为页面加载时必须只执行一次代码:

$(function () {
  // any code in here, is run only once, when the page loads.
});

My understanding is that there can be name-collisions with pageLoad(), whereas the notation above is more reliable. 我的理解是pageLoad()可能存在名称冲突,而上面的表示法更可靠。

At a glance, your datepicker intialization code itself seems correct. 乍一看,您的日期选择器初始化代码本身似乎是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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