Web user control creation - Resolve an ImageUrl property if control themed




I'm creating a WebControl which has a themeable ImageUrl property :

<Bindable(True), Category("Appearance"),
Editor(GetType(System.Web.UI.Design.ImageUrlEditor), GetType
System.Drawing.Design.UITypeEditor)), Description("Image Url"),
DefaultValue(""), Themeable(True), UrlProperty()> _
Public Property ImageUrl() As String
Dim O As Object = Me.ViewState("ImageUrl")
If O Is Nothing Then Return String.Empty Else Return CStr(O)
End Get
Set(ByVal value As String)
Me.ViewState("ImageUrl") = value
End Set
End Property

- First question :

In the RenderContents sub, i render the image with an
MyBase.ResolveClientUrl(Me.ImageUrl)) but this line don't work if the
control on page is skined by a line like this one : <myc:myControl
runat="server" ImageUrl="images/pic.gif" SkinID="myskinid" /> in the theme
..skin file.

In that case, the resolve url in the RenderContents sub return
"images/pic.gif" instead of ~/App_Themes/MyTheme/images/pic.gif, so how to
get the full relative path of the picture ?

- Second question :

For the control i have a control designer which render the control html in a
overrided GetDesignTimeHtml function.

If the control SkinID property is set, when i try CType(Me.Component,
MyControl).ImageUrl in GetDesignTimeHtml function, i get an empty string !?
So, how to get the full relative path of the picture in the designer ?

Thank you in advance for answer.

Olivier I.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question