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
        }

    }


  • 相关阅读:
    单元测试、集成测试、系统测试
    函数
    python中的math函数
    字符串和数据类型转换
    range()函数
    input()函数
    Linux如何通过命令查看日志文件的某几行(中间极几行或最后几行)
    【转】接口测试面试题
    【转】用Fiddler做抓包分析详解
    为什么要使用fiddler抓包?抓包用来干什么?
  • 原文地址:https://www.cnblogs.com/di305449473/p/1245800.html
Copyright © 2011-2022 走看看