Literal控件与TextBox控件结合的自定义复合控件。

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 swanky 的 blog

本控件主要解决了自定义复合控件中,客户端验证脚本。
using system;
using system.web;
using system.web.ui;
using system.web.ui.webcontrols;
using system.componentmodel;

namespace only.compositioncontrols
{
 /// <summary>
 /// create by liyi。
 /// date:2004-10-10
 /// </summary>
 [defaultproperty("value"),validationpropertyattribute("value"),toolboxdata("<{0}:literaltextbox runat=server></{0}:literaltextbox>")]
 public class literaltextbox:control,inamingcontainer
 {
  //以下脚本用于从文本框输入页码
  [defaultvalue("text:"),category("自定义")]
  public string text
  {
   get
   {
    this.ensurechildcontrols();
    return ((literalcontrol)controls[0]).text;
   }
   set
   {
    this.ensurechildcontrols();
    ((literalcontrol)controls[0]).text = value;
   }
  }
  [defaultvalue("value"),category("自定义")]
  public string value
  {
   get
   {
    this.ensurechildcontrols();
    return ((textbox)controls[1]).text;
   }
   set
   {
    this.ensurechildcontrols();
    ((textbox)controls[1]).text = value;
   }
  }
  [defaultvalue(""),category("自定义")]
  public unit width
  {
   get
   {
    this.ensurechildcontrols();
    return ((textbox)controls[1]).width;
   }
   set
   {
    this.ensurechildcontrols();
    ((textbox)controls[1]).width = value;
   }
  }
  [defaultvalue(textboxmode.singleline),category("自定义")]
  public textboxmode textmode
  {
   get
   {
    this.ensurechildcontrols();
    return ((textbox)controls[1]).textmode;
   }
   set
   {
    this.ensurechildcontrols();
    ((textbox)controls[1]).textmode = value;
   }
  }
  [defaultvalue(borderstyle.notset),category("自定义")]
  public borderstyle borderstyle
  {
   get
   {
    this.ensurechildcontrols();
    return ((textbox)controls[1]).borderstyle;
   }
   set
   {
    this.ensurechildcontrols();
    ((textbox)controls[1]).borderstyle = value;
   }
  }
  [defaultvalue(""),category("自定义")]
  public unit borderwidth
  {
   get
   {
    this.ensurechildcontrols();
    return ((textbox)controls[1]).borderwidth;
   }
   set
   {
    this.ensurechildcontrols();
    ((textbox)controls[1]).borderwidth = value;
   }
  }
  protected override void createchildcontrols()
  {
   this.controls.add(new literalcontrol("text:"));

   textbox box = new textbox();
   box.text = "value";
   box.id = "only";
   this.controls.add(box);
  }
 }
}

本文关键:Literal控件与TextBox控件结合的自定义复合控件。
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top