cpaul
-
4/15/2005 10:57:31 PM
Tip for referring to images
I'm using WilsonMasterPages for the overall template of my site, since it's being redesigned as I implement the new solution, and since I had problems using the ASP 2.0 CTP release with Kentico.
Inside the masterpage controls, it won't let you use <%=...%> tags where you could put a ResolveUrl, so I made a simple wrapper of image and imagebutton that do this. The normal <asp:Image> tags get confused by the url rewriting engine when they try to make themselves relative to the master page user control template, and this is the only way I could find to get the images to always be right.
Below is the code for the image control (the ImageButton is the same with different parent class). This might be something easy you could add to the CMS controls in the next release, or included in the documentation for KB0002.
using System; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel;
namespace My.WebControls { /// <summary> /// Summary description for Image. /// </summary> public class Image : System.Web.UI.WebControls.Image {
/// <summary> /// Render this control to the output parameter specified. /// </summary> /// <param name="output"> The HTML writer to write out to </param> protected override void Render(HtmlTextWriter output) { this.ImageUrl = ResolveUrl(this.ImageUrl); base.Render(output); } } }
To use it, register a tag prefix and then use it exactly like a normal <asp:Image> tag. Hope this helps someone.
|