how to call javascript function with Update panel
I have an Update panel in my solution. Update panel contains three columns(div - s) with dynamically added content. I desided that it would be better if each of tree columns would have the same height, and also desided to use javascript function. The problem is: how to call javascript function on event that changes columns height?
I tried to use this on postback event
开发者_开发百科 Page.ClientScript.RegisterStartupScript(this.GetType(), "check", "check()", true);
but this don't works... please help....
use like this, this will help.
System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "resize", "resize()", true);
Most simple way is to use MSAjax pageLoad Event in your javascript code :
<script>
///<summary>
/// This will fire on initial page load,
/// and all subsequent partial page updates made
/// by any update panel on the page
///</summary>
function pageLoad(){ // Write your js code here to adjust height of the columns. }
</script>
I have used it many times, it works like charm. Most important thing is don't confuse it with document.ready function (which will be executed only once after the page Document Object Model (DOM) is ready for JavaScript code to execute),yet pageLoad Event will get executed every time the update panel refreshes.
Source: Running script after Update panel AJAX asp.net
精彩评论