Solved

<script runat=server> to hold Javascript?

Posted on 2006-06-22
5
407 Views
Last Modified: 2006-11-18
Currently i can modify a style sheet during page load.  However, if i want to do this with javascript i need to make a <script runat=server> tag, but then it automatically think's is asp.net code and it's causing errors.

I am after a way to basically do 1 check and to determine what url(src) to use.  The only way i can get it to work is to just Response.Write the whole tag, but that's not a nice solution.  

Does anyone have any ideas?  
0
Comment
Question by:UnexplainedWays
  • 3
5 Comments
 
LVL 4

Expert Comment

by:dukestaTAI
ID: 16962790
Are you using asp.net? If so which version, 1.1 or 2.0?
0
 
LVL 12

Author Comment

by:UnexplainedWays
ID: 16964092
2
0
 
LVL 12

Author Comment

by:UnexplainedWays
ID: 16974332
Guess im trying to do the impossible.
0
 
LVL 3

Accepted Solution

by:
mistaeverly earned 500 total points
ID: 16974481
I'm not sure exactly what you're asking.  You want to modify a style sheet during page load?  Not sure if it helps, but I've linked to an outside javascript file like this before:

<script src="<%= ScriptUrl %>" type="text/javascript"></script>

In this case, ScriptUrl is a public string variable declared in my code-behind.
Hope this helps.


0
 
LVL 12

Author Comment

by:UnexplainedWays
ID: 16974501
I'm after something like that.  What i was trying to do was:

MyUrl

TheScript.src = MyUrl+TheScript.src;


I dont know what MyUrl is untill the page creation.  So to do that i would need to have a runat=server, and as soon as i go down that path i hit the 'not asp.net' brick wall.


The reason why i tried to do change the url like this, is during development (in VS), i was doing the same with style sheets, and then my page would look funny because the sheets only come into action when the page is loaded.

However, thinkign about it a bit more, i realise that VS doesn't do any javascript linking (like how it modifies with css in the development environment).  So i'll have to try that, it should work.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now