ASP.NET更新面板从工作停止的jQuery面板、工作、ASP、NET

2023-09-03 11:35:23 作者:世俗眼光

我已经绑定了的mouseenter鼠标离开,以及jQuery的可拖动设置jQuery的事件。的div被放置在一个更新面板和一个按钮被点击时信息被发送到数据库和更新面板被更新。然而,当面板被更新了jQuery事件不再起作用。任何想法,为什么会这样呢?

I have binded jquery events set for mouseenter mouseleave, as well as jquery draggable. The divs are placed in an update panel and when a button is clicked information is sent to the database and the update panel is updated. However when the panel is updated the jquery events no longer work. Any idea as to why this would be the case?

推荐答案

您可以添加一个异步触发到你的页面的任何异步调用后调用JavaScript / jQuery的功能。

You can add an Asynchronous trigger to your page to call a JavaScript/jQuery function after any async call.

将这个code在你的Page_Load():

Place this code in your Page_Load() of your aspx code behind:

//This script handles ajax postbacks, by registering the js to run at the end of *AJAX* requests
Page.ClientScript.RegisterStartupScript(typeof(Page), "ajaxTrigger", "Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);", true);
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "EndRequest", "function EndRequestHandler(sender, args){AsyncDone();}", true);

这code段将专门调用JavaScript / jQuery的功能AsyncDone();

This code snippet will specifically call the JavaScript/jQuery function AsyncDone();