i have a global variable who hold the value for routing i need to use them to refer the stylesheet like
<%: Globals.routing %> but if i use them to loading stylesheet they never work prehaps the render html soemthing goes like
<link type="text/css" rel="stylesheet" href="<%:Globals.ROOT_PATH %>jqueryui1.8.7.custom.css">
开发者_高级运维
are their any right way to load stylehsheet by passing the location or href tag dynamically
Don't use global variables for this. Use URL helpers:
<link type="text/css" rel="stylesheet" href="<%: Url.Content("~/content/css/jqueryui1.8.7.custom.css") %>" />
Inside the Url.Content
helper you could use some variable to specify user specific paths for the CSS.
Also make sure that the <head>
tag doesn't have a runat="server"
attribute or you might get some bad surprises.
How about:
<link rel="stylesheet" type="text/css" href='<%= ResolveUrl("~/Content/jqueryui1.8.7.custom.css") %>' />
精彩评论