|
|
|
DailyCoding > Web
|
The Script tag runat="server" Problem Solution Using ResolveUrl
|
| Solution to the script tag runat="server" problem |
|
Author
admin on
Jul 21, 2008 |
14 Comments
|
| Rate it |
|
(Rated
4
by
9
people)
|
 |
Loading.. |
|
6,517 Views
|
|
|
This might be an easy trick, but I ran into this issue a while ago; we can not specify the runat="server" attribute on a JavaScript file link as we do for images and style sheet.
<link id="mainSheet" runat="server" href="~/Images/styles.css"
rel="stylesheet" type="text/css" />
By using runat=server the href of the link will automatically be resolved by the asp.net in we have placed ~/ in the path. This gives us advantages when we are linking this into a control and the control could be used by other pages places at a different directory level.
Same problem arise with using linked JavaScript. But this cannot be solved by using runat=server tag. Here is an alternative way to overcome this problem.
<script language="javascript" src="<%=ResolveUrl("~/App_Themes/MainTheme/jquery.js")%>" type="text/javascript"></script>
|
|
ASP.NET
|
Web
|
|
|
|
Stefan
|
On Oct 1, 2008 05:41 AM
|
|
|
|
|
|
kkkkkkkk
|
On Feb 25, 2009 05:01 AM
|
|
|
|
|
Swati
|
On Jun 8, 2009 06:25 AM
|
|
|
|
|
Jason Y
|
On Jul 6, 2009 09:18 AM
|
|
|
|
|
prawin
|
On Jul 23, 2009 12:57 AM
|
|
|
|
|
prawin
|
On Jul 23, 2009 12:57 AM
|
|
|
|
|
Prashant Atal
|
On Aug 20, 2009 01:51 AM
|
|
|
|
|
renato
|
On Oct 12, 2009 11:59 AM
|
|
|
|
|
John Holliday
|
On Jan 6, 2010 04:21 PM
|
|
|
|
|
Derek
|
On Jan 20, 2010 12:00 PM
|
|
|
|
|
Derek
|
On Jan 20, 2010 12:02 PM
|
|
|
|
|
Filip Urbanowicz
|
On Feb 19, 2010 08:42 AM
|
|
|
|
|
Mahesh
|
On Mar 3, 2010 03:09 AM
|
|
|
|
Leave a Comment
|
 |
Loading.. |
|
|
|
|
|