Duplicate Script Reference

Last post 04-09-2007 9:53 AM by lacustris. 2 replies.

Sort Posts:

  • Duplicate Script Reference

    04-05-2007, 5:37 PM
    • Loading...
    • lacustris
    • Joined on 02-13-2007, 4:29 PM
    • Posts 19

    I am trying to create a WebControl dll.  There is a common.js file in the dll.  It is shared bewteen all WebControls.

    If I simply add the script reference using
    ScriptManager.Scripts.Add( ....) or implementing GetScriptReferences function of IScriptControl.  Duplicate script reference will be created when user add multiple web controls.

     It is a problem because a ajax javascript class cannot be registered twice.

    If I use ScriptManager.RegisterClientScriptInclude, the script will be unique but it is inserted before ajax javascript liberary.

     It seems that I have to do something special to make this work.  anyone has suggestions or has experienced the same issue??

    thanks

    Rushui

  • Re: Duplicate Script Reference

    04-05-2007, 11:39 PM
    Answer
    • Loading...
    • paul.vencill
    • Joined on 02-01-2006, 12:57 PM
    • Gaithersburg, MD
    • Posts 683
    Look up the example under ajax.asp.net/docs for the IScriptControl interface.  If you implement the interface using their example as a template you shouldn't have issues; I'm not sure what they're doing under the hood, but the GetScriptReferences method specified is being called in some way that helps avoid conflicts.
  • Re: Duplicate Script Reference

    04-09-2007, 9:53 AM
    • Loading...
    • lacustris
    • Joined on 02-13-2007, 4:29 PM
    • Posts 19

    Upon further investigation, it seems that duplicate script reference of a web control dll can be avoided by implementing GetScriptReference function of IScriptControl interface.  The Scripts collection of ScriptManager however doesnot check for duplicates.

    My situation is a bit strange since I am trying to share a common js lib between the page and the web control dll.  Guess I just have to avoid doing that.

     

    Thanks

     

    Rushui

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter