zoukankan      html  css  js  c++  java
  • asp.net控件开发基础(3)

    类型可供选择的按钮自定义控件
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI;
    using System.ComponentModel;

    namespace ComponentControl
    {
        
    public class Ctrl5:Control,IPostBackEventHandler
        
    {
            
    private static readonly object obj = new object();

            [Description(
    "按钮显示的类型")]
            
    public BtnType ButtonType
            
    {
                
    get return ViewState["ButtonType"== null ? BtnType.Button : (BtnType)ViewState["ButtonType"]; }
                
    set { ViewState["ButtonType"= value; }
            }


            
    //事件
            public virtual event EventHandler Click
            
    {
                add 
    {
                    Events.AddHandler(obj, value);
                }

                remove
                
    {
                    Events.RemoveHandler(obj, value);
                }

            }


            
    //控件重写
            protected override void Render(HtmlTextWriter writer)
            
    {
                
    if (ButtonType == BtnType.Button)
                    writer.Write(
    "<input type=submit name=" + this.UniqueID + " value=Button />");
                
    else if (ButtonType == BtnType.LinkButton)
                    writer.Write(
    "<a href="+Page.GetPostBackClientHyperlink(this,"")+">Button</a>");
            }


            
    IPostBackEventHandler 成员
        }


        
    //按钮类型枚举
        public enum BtnType
        

            Button,
            LinkButton
        }

    }


  • 相关阅读:
    Java动态代理
    图解Python 【第七篇】:网络编程Socket
    我的FP感悟
    Scala微服务架构 三
    Scala微服务架构 二
    Scala微服务架构 一
    一篇入门 -- Scala
    基于DobboX的SOA服务集群搭建
    hadoop 异常及处理总结-01(小马哥-原创)
    使用Eclipse的几个必须掌握的快捷方式(能力工场小马哥收集)
  • 原文地址:https://www.cnblogs.com/di305449473/p/1245800.html
Copyright © 2011-2022 走看看