title: RegisterStartUpScript - clear code when postback occurs
body: <p>I am using a stringbuilder object to concatenate some javascript together and then register it.  My question is, is there a way using client side Javascript to clear that javascript when a postback occurs.  I have found out that when registering arrays using the scriptmanager you have to empty down any dynamic arrays and basically I want to do the same thing with the javascript code that I am dynamically adding to the page?  The javascript has a key ("randomlists") so we must be able to reference it!</p>
  
  <pre><code>ScriptManager.RegisterStartupScript(UpdatePanel_MyPublications, typeof(UpdatePanel), "randomlists", sb_javascript.ToString(), true);
  </code></pre>
  
  <p>Let me explain a little more.  The javascript that I am registering contains some variables, in this case some other arrays which are dynamically populated.  Currently the error is that these arrays are appended to rather than reinstantiated and re-populated (lots of 're' going on) and if I could simply clear and re-register the code all the problems would magically stop...</p>
  
  <p>Thanks.</p>