Tarynn
Tarynn

Reputation: 469

calling javascript from update panel doesn't work

I have the following update panel tag:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" onload="load()">

in my header I have the following:

<script type="text/javascript" >
        function load() {
            doSomething....
        }
</script>

When I run this I get: Compiler Error Message: CS1061: 'ASP.aform_webform2_aspx' does not contain a definition for 'load' and no extension method 'load' accepting a first argument of type 'ASP.aform_webform2_aspx' could be found (are you missing a using directive or an assembly reference?)

Can anyone help me figure out how to call that function whenever my update panel loads?

Upvotes: 2

Views: 1912

Answers (2)

Marwan
Marwan

Reputation: 2402

there is a function also can do

function pageLoad()
{
// do some thing after each partial post back happen
}

Regards

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1039538

There is no onload property on the update panel. You should remove it. You may take a look at the following article. You could use:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(load);

and the load() will be triggered after every update panel update. But if you want to target a specific update panel you could use the following in the code behind:

ScriptManager.RegisterStartupScript(this, this.GetType(), "foo", "load();", true);

Upvotes: 4

Related Questions