I have created a shopping cart application which allows users to specify certain preferences once items are in their cart. Since each cart item can have different preferences I have to dynamically generate the means of getting the preferences for each item. Because I need to maintain view state of the options selected I am dynamically creating these items during the initialization phase of the page life cycle. While dynamically rendering these items I have created a JavaScript array of client ids for various controls that I add JavaScript event handlers to on the client. I register these ClientIDs via the ScriptManager.RegisterStartupScript static method.
This all works marvelously until a user removes an item from the cart. Because the initialization portion of the life cycle executes before the server side click event handler, for removing the item, the items client id is being registered via the ScriptManager.RegisterStartupScript. Which when my client code goes to iterate over and attach event handlers it finds a null item and I get a JavaScript error.
The most obvious solution seems to be to remove the now errant previously registered startup script. Is there a means of removing a single registered startup script via its registered id?
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
This can be beneficial to other community members reading the thread.