zoukankan      html  css  js  c++  java
  • Building ASP.NET Server ControlsTextbox.cs

    // Title: Building ASP.NET Server Controls
    //
    // Chapter: 4 - State Management
    // File: Textbox.cs
    // Written by: Dale Michalk and Rob Cameron
    //
    // Copyright ?2003, Apress L.P.
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Collections.Specialized;
    using System.ComponentModel;

    namespace ControlsBookLib.Ch04
    {
       [ToolboxData("<{0}:Textbox runat=server></{0}:Textbox>"),
       DefaultProperty("Text")]
       public class Textbox : Control, IPostBackDataHandler
       {
           public virtual string Text
          {
             get
             {
                object text = ViewState["Text"];
                if (text == null)
                   return string.Empty;
                else
                   return (string) text;
             }
             set
             {
                ViewState["Text"] = value;
             }
          }

          public bool LoadPostData(string postDataKey,
             NameValueCollection postCollection)
          {
             string postedValue = postCollection[postDataKey];
             Text = postedValue;
             return false;
          }

          public virtual void RaisePostDataChangedEvent()
          {

          }

          override protected void Render(HtmlTextWriter writer)
          {
             Page.VerifyRenderingInServerForm(this);

             base.Render(writer);

             // write out the <INPUT type="text"> tag
             writer.Write("<INPUT type=\"text\" name=\"");
             writer.Write(this.UniqueID);
             writer.Write("\" value=\"" + this.Text + "\" />");
          }
       }
    }
  • 相关阅读:
    Python利用Remove.bg接口自动消除图片背景
    解决ajxa跨域问题
    CentOS7 修改静态IP
    CentOS下 安装composer 与tp5.1
    centon 安装php-fpm+Nginx
    win10 安装selenium和使用
    Scrapy 爬虫框架入门
    Python 异常处理
    selenium和phantomjs的介绍
    MongoDB入门
  • 原文地址:https://www.cnblogs.com/shihao/p/2498645.html
Copyright © 2011-2022 走看看