webcustomcontrol1.cs

来自「水晶报表详细资料水晶报表详细资料水晶报表详细资料」· CS 代码 · 共 75 行

CS
75
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;
namespace MyLabel
{
    [
    AspNetHostingPermission(SecurityAction.Demand,Level = AspNetHostingPermissionLevel.Minimal),
   AspNetHostingPermission(SecurityAction.InheritanceDemand,Level = AspNetHostingPermissionLevel.Minimal),
   DefaultProperty("Text"),
   ToolboxData("<{0}:WebCustomControl1 runat=\"server\"> </{0}:WebCustomControl1>")
   ]
    public class WebCustomControl1 : WebControl
    {
        public string textName;
        public int intMax;
        [
           Bindable(true),
           Category("Appearance"),
           DefaultValue(""),
           Description("显示文本!"),
           Localizable(true)
       ]
        public virtual string Text
        {
            get
            {
                string s = (string)ViewState["textName"];
                return (s == null) ? String.Empty : s;
            }
            set
            {
                ViewState["textName"] = value;
            }
        }
        [
            Bindable(true),
            Category("Appearance"),
            DefaultValue(""),
            Description("设置当前日期!"),
            Localizable(true)
        ]
        public virtual int intYear
        {
            get
            {

                return intMax;
            }
            set
            {
                intMax = value;
            }
        }
        protected override void RenderContents(HtmlTextWriter writer)
        {
           
            if ((Text != "")&&(intYear.ToString() != ""&& intYear > 1990))
            {
             writer.Write("<h2>" + Text +":"+ intYear.ToString()+ "</h2>");
            }
            else
            {
                writer.Write("<h2>" + "默认年份:" + DateTime.Now.Year.ToString() + "</h2>");
            }
         
           
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?