jQuery的高亮效果不工作在asp.net更新面板 [英] jquery effect highlight not working in asp.net update panel
问题描述
我有两个更新的面板如下(当LinkButton控件被点击我想要强调的div)
i have two update panels as follows (when linkbutton is clicked i'm trying to highlight div)
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Linkbutton id="btnChange" runat="server" OnCommand="LinkButton_Command"/>
<asp:Linkbutton id="btnChange2" runat="server" OnCommand="LinkButton_Command"/>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<div id="shdr">Hello there!</div>
</ContentTemplate>
</asp:UpdatePanel>
我压倒一切的onLoadComplete和页面上注册该脚本如下:
I'm overriding OnLoadComplete and registering this script on page as follows
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "divHigh", "$('#shdr').effect('highlight', {}, 3000);", True)
这突出了股利后回传,但超时值不工作也继续显示高亮显示的颜色并不会改回来。
This highlights the div after postback but the timeout value doesn't work it continues to show highlighted color and doesn't change back.
有什么可以导致此不工作?
What can be causing this not to work?
推荐答案
如果你使用一个UpdatePanel - 即脚本管理器
If you're using an UpdatePanel - i.e. a Script Manager
$(function () {
//Code that runs before update panel is fired.
//Listen for update panel
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
//Re-initialize jquery after an auto post back.
function EndRequestHandler(sender, args) {
//Do work after update panel fires.
}
});
所以基本上你有你自己的jQuery code,然后在 EndRequestHandler
函数中相同的code,如果你希望它能够后运行后回来。
So essentially you will have your jQuery code and then the same code inside the EndRequestHandler
function if you want it to be able to run after a post back.
这篇关于jQuery的高亮效果不工作在asp.net更新面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!