I'm using a jQuery tip plugin to show help tips when the user hovers certain elements of the page.
I need to register the plugin events after the page is loaded using css selectors.
The problem is I'm using an ASP.NET Update Panel and after the first postback, the tips stop working because the update panel replaces the page content but doesn't rebind the javascript events.
I need a way to execute a javascript callback after the Update Panel refreshes its content, so I can rebind the javascript events to have the tips working again.
Is there any way to do this?
Postback is a term that gets introduced very recently by ASP . NET programming as Dreas explained, whereas callback is more generic and has been used way before web development exists.
How to Raise a Postback from JavaScript? To do this, we need to just call the __doPostBack() function from our javascript code. When the above function is called, it will raise a postback to server.
Use the AsyncPostBackTrigger control to enable controls to be triggers for an UpdatePanel control. Controls that are triggers for an update panel cause a refresh of the panel's content after an asynchronous postback.
AsyncPostBackTrigger - use these triggers to specify a control within or outside of the UpdatePanel that, when clicked, should trigger a partial page postback. PostBackTrigger - use these triggers to have a control within the UpdatePanel cause a full page postback rather than a partial page postback.
Instead of putting your jQuery code inside of $(document).ready()
, put it inside
function pageLoad(sender, args) { ... }
pageLoad
is executed after every postback, synchronous or asynchronous. pageLoad
is a reserved function name in ASP.NET AJAX that is for this purpose. $(document).ready()
on the other hand, is executed only once, when the DOM is initially ready/loaded.
See this Overview of ASP.NET AJAX client lifecycle events
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With