Now this is annoying me, I’m trying to take an existing classic ASP solution and convert it to ASP.Net 2.0 as a learning exercise. The problem is that I’m struggling to convert this –
<head>
<title>A Page</title>
<% if intCategoryID < 3 then %>
<script language="javaScript"
src="http://www.foo.com/foo.js"></script>
<% end if %>
</head>
So, I want to only include the JavaScript if a condition is met (in this case intCategoryID < 3). How do I achieve this in ASP.Net?? I have looked at an asp:literal tag to achieve this but Visual Web Developer suggests a literal cannot include child tags (the script tag itself). Can I add one programmatically from the codebehind?
I hope I can find a solution to this..
September 14, 2006 at 8:04 pm
Did you ever find a solution to this?
September 15, 2006 at 8:58 am
I think I did Mike. I’ll see if I can find something and post later on Today (hopefully).
Edit: i’ll take a look at this next week.
September 18, 2006 at 5:14 pm
A simple approach (taken from here is something like this in your codebehind –
You could also use RegisterClientScriptInclude as detailed here