I have build a Custom Control with an ImageURL property. At design time when I enter an image in the ImageUrl I get the following error message
Error Creating Control - AmazeDropDownList1'~/Image/help.png' could not be set on property 'ImageUrl'.
<myCompany:MyCompanyDropDownList ID="AmazeDropDownList1" runat="server" ImageUrl="~/Image/help.png">
</myCompany:MyCompanyDropDownList>
The code for my control is shown below:
[DefaultValue("")]
[Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[Description("Image_ImageUrl")]
[Bindable(true)]
[Category("Appearance")]
[UrlProperty]
public virtual string ImageUrl
{
get
{
string str = (string)this.ViewState["ImageUrl"];
if (str != null)
{
return str;
}
return string.Empty;
}
set
{
this.ViewState["ImageUrl"] = value;
}
}
I am inheriting from TextBox, below is my render method:
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
// Call the base class's Render method.
base.Render(writer);
if (!string.IsNullOrEmpty(this.ImageUrl))
{
// Create and render a new Image Web control.
System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image();
image.ID = "Image1";
image.ImageUrl = ImageUrl;
image.AlternateText = ImageAltText;
image.RenderControl(writer);
}
}
I would really appreciate any help in fixing the error message.