日期:2014-05-18 浏览次数:20568 次
[ToolboxData("<{0}:BigImageButton runat=server></{0}:BigImageButton>")] public class BigImageButton : Button { private string GetDefaultImageUrl() { return Page.ClientScript.GetWebResourceUrl(GetType(), "myCustomControl.images.BigButton.gif"); //这个图片的类型为嵌入的资源 } protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none"); writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage, String.Format("url({0})", GetDefaultImageUrl())); //指定背景图片 writer.AddStyleAttribute(HtmlTextWriterStyle.Width,"85px"); writer.AddStyleAttribute(HtmlTextWriterStyle.Padding,"0 0 0 0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "23px"); } }