Force UpdatePanel Postback example

how to call an asp button_click from JS
http://www.aaronkjackson.com/2009/05/calling-a-button-click-from-javascript-in-aspnet/
now put a button named btnLogin INSIDE the UpdatePanel
what happens is that the btnLogin_Click() calls the submit OF THE BUTTON!
CS:
protected string GetLoginPostBack() {
            return Page.ClientScript.GetPostBackEventReference(btnLogin, string.Empty);
}
SCRIPT:
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

Comments

Popular posts from this blog

OverTheWire[.com] Natas Walkthrough - JUST HINT, NO SPOILERS

Asp.Net Ending Response options, Response.End() vs CompleteRequest()

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem