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
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