I have created visual web part and copied custom web control which I'd like to use. My control looks as below:
namespace AppsListWebPart
{
[ToolboxData("<{0}:CustomImageButton runat=\"server\"></{0}:CustomImageButton>")]
public class CustomImageButton : LinkButton
{
public string ImageUrl { get; set; }
/// <summary>
/// This image will override any background mentioned in CSS. Use this in case you want to use ASP.net (non-CSS) style URLs (like ~/images/add.png)
/// </summary>
public string BackgroundImageUrl { get; set; }
public override void RenderBeginTag(HtmlTextWriter writer)
{
if (!string.IsNullOrEmpty(this.BackgroundImageUrl))
{
base.Style.Add("background", "url('" + base.ResolveUrl(this.BackgroundImageUrl) + "‘) left center no-repeat");
}
base.Style.Add("text-decoration", "none");
base.Style.Add("text-align", "center");
base.RenderBeginTag(writer);
}
protected override void RenderContents(HtmlTextWriter writer)
{
writer.Write("<span style='vertical-align:top;'>");
base.RenderContents(writer);
writer.Write("</span>");
writer.Write("<img border='0′ style='margin-top:2px;margin-left:3px' src='" + base.ResolveUrl(this.ImageUrl) + "‘ />");
}
}
}
In my webpart's ascx file, I try to register this web control by:
<%@ Register TagPrefix="spt" Namespace="AppsListWebPart" %>
Unfortunately, IntelliSense doesn't show any spt: tags and when I try to run my web part with this code written by myself:
<spt:CustomImageButton runat="server"></spt:CustomImageButton>
I get the error: Unknown server tag 'spt:CustomImageButton'.
How to perform correct custom web control registration?
Edit
I changed the registration line to:
<%@ Register TagPrefix="spt" Namespace="AppsListWebPart.AppsListVisualWebPart" Assembly="AppsListWebPart" %>
and changed my web control namespace to AppsListWebPart.AppsListVisualWebPart
and I'm getting now:
Could not load file or assembly 'AppsListWebPart' or one of its dependencies. The system cannot find the file specified.
In editor thou, when I enter spt: I see now my AppsListVisualWebPartUserControl
, but not CustomImageButton
.
In webconfig I found AppsListWebPart assembly registered in safecontrols, but nothing more.