Solved

<script runat=server> to hold Javascript?

Posted on 2006-06-22
5
411 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This video teaches users how to migrate an existing Wordpress website to a new domain.

776 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