JQueryUI 和 ASP.NET UpdatePanel 之争?有什么快速的替代方案吗?
我使用 asp.net 编程仅几个月,我必须维护一个由许多带有更新面板的 aspx web 表单组成的应用程序。
维护的任务之一是集成一些 JQueryUI 小部件(主要是日期选择器、选项卡和按钮)。
我在顺利执行此操作时遇到一些问题,特别是当控件
- 位于更新面板内
- 时通常在任何模板化控件内(例如向导控件)
例如这个非常简单的代码:
<script type="text/javascript">
$(document).ready(function() {
$("#myTabs").tabs();
$("[ID$=TextBox2]").datepicker();
$("[ID$=btnOk]").button();
});
</script>
<div>
Jquery UI controls inside a div (Tabs, datepicker and buttons)
<br />
<div id="myTabs">
<ul>
<li><a href="#myTabs-1">quick sample</a></li>
</ul>
<div id="p-tabs-1">
<p>In this page there are a datepicker control and a button</p>
<p>
Please select a date :<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnOk" runat="server" Text="Ok" OnClientClick="btnOk_Click" />
</p>
</div>
</div>
</div>
将立即停止如果放在更新面板中,
是否有解决方案,或者我必须采用完全不同的方法?
非常感谢 ,什么是最好的替代方法?很多 洛伦佐
I have been using asp.net programming just from few months and I have to maintain an application that is made up of many aspx webforms with updatepanels.
One of the task of the maintenance is to integrate some of the JQueryUI widgets (mostly datepicker, tabs and buttons).
I am experiencing some problems on doing this smoothly expecially when the controls are
- Inside an update panel
- Generally inside any templated control (e.g. Wizard control)
For example this very simple code:
<script type="text/javascript">
$(document).ready(function() {
$("#myTabs").tabs();
$("[ID$=TextBox2]").datepicker();
$("[ID$=btnOk]").button();
});
</script>
<div>
Jquery UI controls inside a div (Tabs, datepicker and buttons)
<br />
<div id="myTabs">
<ul>
<li><a href="#myTabs-1">quick sample</a></li>
</ul>
<div id="p-tabs-1">
<p>In this page there are a datepicker control and a button</p>
<p>
Please select a date :<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnOk" runat="server" Text="Ok" OnClientClick="btnOk_Click" />
</p>
</div>
</div>
</div>
will immediately cease to work if placed inside an update panel.
Do there is a solution regarding this issue or I have to follow a completely differnt approach? Do I have to substitute all the updatepanels? And what is the best alternative to this easy to use control?
Thanks very much
Lorenzo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应用 Chuck 建议后,我收到了 javascript 错误(Sys 未定义)。
谷歌搜索把我带到了这个网站 帖子解决了我的问题。
现在一切正常了! :)
After applying Chuck suggestion I was getting a javascript error (Sys is not defined).
Googling around tooked me at this web post that solved my problem.
Now everything works! :)
请参阅:jQuery $(document).ready 和 UpdatePanels?
updatepanel 会销毁所有 javascript 引用,其中包括 jquery 绑定。如果不这样做,就会造成内存泄漏。
See: jQuery $(document).ready and UpdatePanels?
An updatepanel destroys all javascript references, which includes jquery bindings. If it did not do this it would create a memory leak.