Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

<script runat=server> to hold Javascript?

Posted on 2006-06-22
5
Medium Priority
?
420 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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

972 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