1

I use the following my .net applications to resolve the path to an image or css file or javascript file.

<%=ResolveUrl("~/Scripts/myscript.js")%>

<%=ResolveUrl("~/images/myimage.jpg")%>

All my pages and controls inherit from a base page or base user control.

I have tried but didnt succeed in overriding the ResolveUrl method so that I could include some custom logic in the files path.

Any ideas how I might override the ResolveUrl method? Alternative is to create my own custom method that does similar but would prefer to work with ResolveUrl.

amateur
  • 43,371
  • 65
  • 192
  • 320
  • 1
    Not sure what sort of custom function you need, but you might find the following helpful: HttpContext.Current.Response.ApplyAppPathModifier and AppRelativeTemplateSourceDirectory (A property on control). These two, combined with the path you are trying to resolve, can give you the same effect as ResolveUrl. – Peter Dec 14 '10 at 21:11

2 Answers2

4

ResolveUrl is not virtual so you will have little success using an override and it does not internally use anything that you can override to customize the functionality. That leaves you with writting your own utility function.

Chris Taylor
  • 52,623
  • 10
  • 78
  • 89
1

I would create your own ResolveCustomUrl method so that future developers don't go crazy

hunter
  • 62,308
  • 19
  • 113
  • 113