Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

RegisterStartupScript Is Placing Script Block at Top of the Form

$
0
0

I'm developing a custom server control which uses ScriptManager.RegisterStartupScript to invoke a function when the page is loaded.

All works fine except for the following scenario.

The control is contained within an UpdatePanel.  On initial page load the control's Visible property is set false so no rendering of the control occurs.  A button is clicked which is a trigger for the UpdatePanel and the async Postback occurs.  During the async Postback, the control's Visible property is set to true and the ResisterStartupScript method is called by the control.  On the client I see the function being invoked by the script block emitted by RegisterStartupScript.  The problem is the script block was placed in the Head tag of the Form, not at the end of the Form as I expected; this causes the function to fail because the control has not yet been rendered on the page.

Why would ScriptManager.RegisterStartupScript place the script block in the Head tag of the Form during an async Postback after making the control visible?

Thanks


Viewing all articles
Browse latest Browse all 5678

Trending Articles