问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Linq;usingSystem.Text;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;namespacecontrols{[DefaultProperty("Text")][ToolboxData("<{0}:ctlDBImgBtnsrunat=server></{0}:ctlDBImgBtns>")]publicclassctlDBImgBtns:WebControl{privateImageButtonmbtnAddNew;//按钮对应事件privatestaticreadonlyobjectmbtnAddNewHandler=newobject();protectedoverridevoidCreateChildControls(){Controls.Clear();mbtnAddNew=newImageButton();mbtnAddNew.AccessKey="A";mbtnAddNew.ToolTip="ALT+A";mbtnAddNew.Click+=newImageClickEventHandler(mbtnAddNew_Click);this.Controls.Add(mbtnAddNew);this.ChildControlsCreated=true;}protectedoverridevoidRenderContents(HtmlTextWriteroutput){EnsureChildControls();//output.Write(Text);mbtnAddNew.RenderControl(output);mbtnEdit.RenderControl(output);mbtnDel.RenderControl(output);mbtnSave.RenderControl(output);mbtnCancel.RenderControl(output);mbtnAudit.RenderControl(output);mbtnReject.RenderControl(output);mbtnQuery.RenderControl(output);mbtnPrint.RenderControl(output);mbtnExport.RenderControl(output);}protectedoverridevoidRender(HtmlTextWriterwriter){RenderContents(writer);}//[Bindable(true)]//[Category("Appearance")]//[DefaultValue("")]//[Localizable(true)]//publicstringText//{//get//{//Strings=(String)ViewState["Text"];//return((s==null)?String.Empty:s);//}//set//{//ViewState["Text"]=value;//}//}/////<summary>/////设置按钮当前页类型/////</summary>//[Bindable(false)]//[DefaultValue(btnPageType.BASE)]//[Description("设置按钮当前页类型")]//publicbtnPageTypesetPageType//{//set//{//if(this.ViewState["PageType"]!=null)//{//this.ViewState["PageType"]=value;//}//else//{//this.ViewState.Add("PageType",value);//}//}//}#region新增按钮属性,方法及事件[Category("Appearance")][DefaultValue("")][Description("获取或设置新增按钮SkinID值")]publicstringbtnAddSkinID{get{EnsureChildControls();stringlSkinID=mbtnAddNew.SkinID;return(lSkinID==null)?string.Empty:lSkinID;}set{mbtnAddNew.SkinID=value;}}[Category("Appearance")][DefaultValue("")][Description("获取或设置新增按钮ImageUrl值")]publicstringbtnAddImgUrl{get{EnsureChildControls();stringlImgUrl=mbtnAddNew.ImageUrl;return(lImgUrl==null)?string.Empty:lImgUrl;}set{EnsureChildControls();mbtnAddNew.ImageUrl=value;}}[Category("Appearance")][DefaultValue("")][Description("获取或设置新增按钮访问权限值")]publicBooleanbtnAddNewAccess{get{objectlIsAccess=this.ViewState["btnAddNewAccess"];return((lIsAccess!=null)&&(lIsAccess.ToString().Trim().ToUpper()=="TRUE"))?true:false;}set{this.ViewState.Add("btnAddNewAccess",value);}}///<summary>///增加新增按钮客户端脚本///</summary>///<paramname="pKey">键名</param>///<paramname="pValue">值</param>publicvoidaddBtnAddNewScript(stringpKey,stringpValue){if(mbtnAddNew!=null){mbtnAddNew.Attributes.Add(pKey,pValue);}return;}///<summary>///移除新增按钮客户端脚本///</summary>///<paramname="pKey">键名</param>publicvoidremoveBtnAddNewScript(stringpKey){if(mbtnAddNew!=null){mbtnAddNew.Attributes.Remove(pKey);}return;}[Description("新增按钮事件")]publiceventImageClickEventHandlerbtnAddNewOnClick{add{Events.AddHandler(mbtnAddNewHandler,value);}remove{Events.RemoveHandler(mbtnAddNewHandler,value);}}voidmbtnAddNew_Click(objectsender,ImageClickEventArgse){btnAddNew_Click((ImageClickEventArgs)ImageClickEventArgs.Empty);}protectedvirtualvoidbtnAddNew_Click(ImageClickEventArgse){ImageClickEventHandlerlHandler=(ImageClickEventHandler)Events[mbtnAddNewHandler];if(lHandler!=null){lHandler(this,e);}}#endregion
解决方案
解决方案二:
}