Literal控制項與TextBox控制項結合的自訂複合控制項

來源:互聯網
上載者:User
控制項 本控制項主要解決了自訂複合控制項中,用戶端驗證指令碼。
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);
}
}
}





相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。