Wednesday, May 9, 2012

Force UpdatePanel Postback example

how to call an asp button_click from JS
now put a button named btnLogin INSIDE the UpdatePanel
what happens is that the btnLogin_Click() calls the submit OF THE BUTTON!
protected string GetLoginPostBack() {
            return Page.ClientScript.GetPostBackEventReference(btnLogin, string.Empty);
function btnLogin_Click() {    
        <%= GetLoginPostBack() %>;
done :)
now u can call it from anywhere in ur js code to actually force the UPP.

my postback call was right after DB update so i needed a sec, this is the js:
setTimeout(function() {btnSecretPostback_Click();},1250); //mls

*doesnt matter asp or html and u can give him display:none for invisibility, W/O onclick or something like that

No comments:

Post a Comment