making server component themeable?

P

Patrick F

Hi, i created a server control, but how can i add my server control to the
skin file with some default attributes?

Here is what i get when i try:
this.@__controlSkins[@__BuildControl__control2_skinKey] = new
System.Web.UI.ControlSkin(typeof(LaberImage.LaberImage), new
System.Web.UI.ControlSkinDelegate(this.@__BuildControl__control2));

Here is the skin file:
<asp:LaberImage ThemeName="Test1" runat="server" />

Here is the control:
using System;
using System.Web.UI.WebControls;
using System.Web.UI;

namespace LaberImage
{
[Themeable(true)]
public class LaberImage : System.Web.UI.WebControls.Image
{
public LaberImage()
{
}

private string imageName = string.Empty;
public string ImageName
{
get
{
return imageName;
}
set
{
imageName = value;
}
}
private string themeName = string.Empty;
public string ThemeName
{
get
{
return themeName;
}
set
{
themeName = value;
}
}
protected override void OnPreRender(EventArgs e)
{
if ((System.Web.HttpContext.Current.Session["theme"] == null) ||
(System.Web.HttpContext.Current.Session["theme"].ToString() == ""))
ImageUrl = "/App_Themes/" + themeName + "/" + imageName;
else
ImageUrl = "/App_Themes/" +
System.Web.HttpContext.Current.Session["theme"] + "/" + imageName;

base.OnPreRender(e);
}
}
}

any ideas?
Patrick
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top