Click here to Skip to main content
14,695,387 members
Please Sign up or sign in to vote.
1.67/5 (6 votes)
See more:
Hi!

I have 5 different javascript tags in my html page like:
<script type="text/javascript" src="js/boxOver.js"></script>
<script type="text/javascript" src="js/boxiner.js"></script>
.
.
.<script type="text/javascript" src="js/over.js"></script>

I want to select a particular tag and delete it using Asp.Net. Can somebody tells me how to do it?

thanks in advance
Posted
Updated 28-Jun-12 9:24am
v2
Comments
Sergey Alexandrovich Kryukov 28-Jun-12 13:57pm
   
Why?!! and why writing an element to be deleted in first place? I think it makes no sense, whatsoever.
--SA
saifullahiit 28-Jun-12 14:02pm
   
if you have a solution for that please let me know. the question "why" is i think has no sense here. ;)
Manfred Rudolf Bihy 28-Jun-12 14:21pm
   
What SA means is you are in control on the server side, so you can decide in your page's code behind what will be rendered an what not. If you don't need a certain script tag on your rendered page, then don't render it.

Simples, really!
Sandeep Mewara 28-Jun-12 14:28pm
   
:thumbs up:
Manfred Rudolf Bihy 29-Jun-12 6:34am
   
:)
R. Giskard Reventlov 28-Jun-12 15:45pm
   
Should be the solution.
Manfred Rudolf Bihy 29-Jun-12 6:34am
   
Thanks Mark!

1 solution

What I would do is remove the script tag from the aspx page and then you can use some logic and if you do decide you want it loaded in the C# you can do

Page.ClientScript.RegisterClientScriptInclude("jQuery",ResolveClientUrl("Common/Scripts/jquery.min.js"));


The problem with trying to remove it client side is that if there is any code in it that runs on document ready then it will have already run by the time you go to remove it.

However, you can try getting to it using document.scripts and try the remove() jQuery command. I still do not recommend this. I recommend trying to get to your end result a different way.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900