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 + "\" />");
          }
       }
    }
  • 相关阅读:
    05 | 深入浅出索引(下)
    04 | 深入浅出索引(上)
    03 | 事务隔离:为什么你改了我还看不见?
    02 | 日志系统:一条SQL更新语句是如何执行的?
    01 | 基础架构:一条SQL查询语句是如何执行的?
    orm的惰性机制
    简易的迁移
    rails 中 preload、includes、Eager load、Joins 的区别
    换种方式去分页
    Scala function programming
  • 原文地址:https://www.cnblogs.com/shihao/p/2498645.html
Copyright © 2011-2022 走看看