2

In my masterpage, I use the code binding expression shown below so that aspx pages not in the same directory as the masterpage are able to load properly.

To provide further context, this is an "ASP.NET Website" and not MVC. I verified that I was not able to apply "Microsoft ASP.NET Web Optimization Framework" to my website because it is designed for MVC.

Is there another way supply the href attribute value without using a code binding expression (otherwise known as a code nugget)?

<link 
      href="<%# Page.ResolveURL("/~Theme/redmond/jquery-ui-1.10.3.custom.min.css") %>" 
      rel="stylesheet" type="text/css" />
  • http://stackoverflow.com/a/10980690/17447 this is the way to use it. both scripts and stylesheets – naveen May 11 '15 at 03:53
  • The link and the "Microsoft ASP.NET Web Optimization Framework" appear to be designed for MVC. My system is a Website. I am not sure if this will work for me, as I do not see "App_Start" in my solution folders, even after refreshing. –  May 11 '15 at 04:07
  • In webforms, there is no other way if you want to create a relative url without causing problems while pages are in different location. I would prefer Page.ResolveUrl instead of Page.ResolveClientUrl. Here is a link to know the difference between them. http://www.andornot.com/blog/post/ResolveUrl-vs-ResolveClientUrl.aspx – Kiran Varsani May 11 '15 at 04:15
  • In the context of script and link URLs in the head section, this makes perfect sense. I verified it just now. So is "there is no other way" for webforms the answer? –  May 11 '15 at 04:18

0 Answers0