AJAX ScriptManager.RegisterStartupScript - JavaScript accumulates


M

Mojo-U

Hello,

I have a custom server control that is being used from within an AJAX
UpdatePanel.

The server control is AJAX-aware and uses the
ScriptManager.RegisterStartupScript() method to execute some JavaScript after
the AJAX postback has occured and the HTML within the UpdatePanel has been
updated.

Using the IE Developer Toolbar I am able to see the source of the page after
an AJAX postback occurs. Each time a postback occurs, I can see the new
block of JavaScript contained in the page, along with the same block of
JavaScript which was added to the page on all previous AJAX postbacks.

The net effect is that whatever JavaScript I want to add via my call to
RegisterStartupScript gets re-added to the page each time an AJAX postback
occurs. This seems like it could be a problem if my page makes a large
number of AJAX postbacks over time. The page would actually grow in length.

Is there a technique I should be using that avoids this problem, or is this
not actually a "problem" at all?

Thanks,
Matt
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top