Javascript event on page postback

asp.net, c#, javascript

Solution

Take a look at: Run javascript function after Postback

I solved my problem using this:

<script type="text/javascript">
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function (s, e) {
        alert('Postback!');
    });
</script>

there are a lot of options too, like

$('#id').live('change', function (){});

$(document).ready(function () {});
ClientScriptManager.RegisterStartupScript(this.GetType(), "AKey", "MyFunction();", true);

and keep going. depends on what you need.

PageRequestManager events: https://learn.microsoft.com/en-us/previous-versions/aspnet/bb398976(v=vs.100)

Problem

Is there any javascript event which is triggered on postback? If not, how can I run client side code immediately after or before a page postback?

Original source

Related problems