Friday, October 9, 2009

ResolveUrl

If you ever need to resolve the location of a resource in your code behind, use this sweet little function. This is especially useful in a Master Page or a User Control where the relative location of a resource will change.

Here is an example that dynamically adds some JavaScript onmouseout code for an image rollover:

imgImage.Attributes.Add("onmouseout", "src='" + ResolveUrl("~/Images/something_active.gif") + "'");

No comments:

Post a Comment