issue in loading js file dynamically

asp.net , javascript Madrid, Spain
  • 12 years ago
    I added these codes in the javascript file
     
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_pageLoaded(CheckLoadBody);
     
    This will be triggered each time when the Updatepanel loads,so I can able to call the method when i access the transaction page second time.
    i.e.When the Updatepanel is loaded the method is triggered.
     
    But the problem is If I access the Cashdeposit first time and the CashWithdrawal secondtime,
    During Cashwithdrawal its calling the load method of cashdeposit also.
     
    This is because when I initially load the CashDeposit CashDeposit.js is is added.
    And if I access CashWithdrawal CashWithdrawal.js is added,here I have to remove the script reference of CashDeposit.js
    So is there anyway to remove the script file that is initially added when I access the new transaction?
     
    This is the Code I used to add the Javascript file dynamically
     
    <asp:ScriptManagerProxy runat="server" ID="scrMain">
    </asp:ScriptManagerProxy>              
     
    string txnJS = "../ClientScripts/" + SessionManager.CurrentTransName + ".js";
    ScriptReference dynamicJS = new ScriptReference(txnJS);
    scrMain.Scripts.Add(dynamicJS);

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If Java had true garbage collection, most programs would delete themselves upon execution.” - Robert Sewell