ScriptManager Remove Registered Startup Scripts

Last post 05-16-2008 12:59 AM by iumer. 5 replies.

Sort Posts:

  • ScriptManager Remove Registered Startup Scripts

    02-15-2008, 1:48 PM
    • Loading...
    • ahsteele
    • Joined on 01-19-2007, 9:34 PM
    • Albuquerque, NM
    • Posts 110

    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.
  • Re: ScriptManager Remove Registered Startup Scripts

    02-21-2008, 4:34 AM

    Hi,

    Thank you for your post!

    As far as I know, there is no use to remove the setup script, because the setup script just run one time.

    What you need to do is to remove the client Id of the removed item from the JavaScript array you created.

    If you have further questions,let me know!

    Best Regards,

    Sincerely,
    Jin-Yu Yin
    Microsoft Online Community Support
  • Re: ScriptManager Remove Registered Startup Scripts

    03-13-2008, 1:59 AM
    Answer
    • Loading...
    • ahsteele
    • Joined on 01-19-2007, 9:34 PM
    • Albuquerque, NM
    • Posts 110

    I get what you are saying but the problem is that because of the way the Page LifeCycle works I've already added the id to the array.  If I can modify the startup script that'd work as well.  For now I am just checking to see if the object is null on the client.  Ie I still find it in the array but before looking for that object I ensure if it is on the page or not.  Not perfect and I'd prefer to remove it, but I see no way to remove/modify something I've already added to the startup script.

     

    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.
  • Re: ScriptManager Remove Registered Startup Scripts

    03-13-2008, 2:20 AM
    • Loading...
    • moredotnet
    • Joined on 11-24-2006, 12:07 PM
    • Millenium City
    • Posts 748

    This may be handled in the endRequest event of the PageRequestManager object.

    Vishal Khanna

    .NET Interviews & FAQs @ www.dotnetUncle.com




    Click Mark as Answer if the reply helped you.
  • Re: ScriptManager Remove Registered Startup Scripts

    03-13-2008, 2:26 AM
    • Loading...
    • ahsteele
    • Joined on 01-19-2007, 9:34 PM
    • Albuquerque, NM
    • Posts 110

    In what manner?  Removing the item added to the script or only adding the items during the endRequest of the PageRequestManager?

    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.
  • Re: ScriptManager Remove Registered Startup Scripts

    05-16-2008, 12:59 AM
    • Loading...
    • iumer
    • Joined on 12-18-2006, 7:08 AM
    • Posts 115

    can you please provide intro code that could remove strartupscript

    Umer Khan
    Sr. Software Engineer
    Umer.Khan@systemsltd.com
    ------------------------
    Click "Mark As Answer"
    iff,It helped You
Page 1 of 1 (6 items)
Microsoft Communities
Page view counter