为什么更新面板中的JQUERY日期选择器不起作用? [英] Why JQUERY date picker inside update panel doesn't work?

查看:69
本文介绍了为什么更新面板中的JQUERY日期选择器不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery datePicker在我的应用程序中运行得非常好。但是当我使用AJAX更新面板时。它不会起作用。可能是什么原因?我认为因为Textbox在ContentTemplate中,所以它的ID可能不适用于jQuery。只是想知道为什么它不能在updatepanel内工作?

解决方案

在你的UpdatePanel中,在你的测试盒上添加css类

< asp:UpdatePanel ID =UpdatePanel1runat =server>
< ContentTemplate>
< asp:TextBox ID =TextBox1runat =serverCssClass =classTarget>< / asp:TextBox>
.....
< / ContentTemplate>
< / asp:UpdatePanel>
在你的脚本中添加此代码

< script type =text / javascriptsrc =http://jqueryjs.googlecode.com/files/jquery-1.3.1.js >
< / script>
< script type =text / javascript>


(document).ready(function(){
Sys.WebForms.PageRequestManager.getInstance() .add_endRequest(EndRequestHandler);

函数EndRequestHandler(sender,args){


('。classTarget).datepicker({dateFormat:'dd-mm-yy '});
}

});
< / script>


jQuery datePicker is working very fine in my application. But when I use AJAX update panel. It won't work. What might be the reason? I think since the Textbox is inside ContentTemplate its ID might not be available for jQuery. Just wanted to know why it is not working inside updatepanel?

解决方案

In your UpdatePanel add css class on your test box

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
           <asp:TextBox ID="TextBox1" runat="server" CssClass="classTarget"></asp:TextBox>
           ..... 
        </ContentTemplate>
</asp:UpdatePanel>
In your script add this code

   <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.js">
   </script>
   <script type="text/javascript">


(document).ready(function() { Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function EndRequestHandler(sender, args) {


('.classTarget).datepicker({ dateFormat: 'dd-mm-yy' }); } }); </script>


这篇关于为什么更新面板中的JQUERY日期选择器不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆