using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Drawing;
using System.ComponentModel;
using System.Web.UI;
namespace XControl
{
/// <summary>IPµØÖ·ÊäÈë¿Ø¼þ¡£Ö»ÄÜÊäÈëÊý×Ö£¬²¢¿ÉÒԹ涨·¶Î§¡¢¼ä¸ô¡£</summary>
[Description("ÈÕÆÚÑ¡Ôñ¿Ø¼þ")]
[ToolboxData("<{0}:IPBox runat=server></{0}:IPBox>")]
[ToolboxBitmap(typeof(TextBox))]
public class IPBox : TextBox
{
/// <summary>³õʼ»¯IPµØÖ·ÊäÈë¿Ø¼þµÄÑùʽ¡£</summary>
public IPBox()
: base()
{
this.ToolTip = "Ö»ÄÜÊäÈëIPµØÖ·£¡";
BorderWidth = Unit.Pixel(0);
BorderColor = Color.Black;
BorderStyle = BorderStyle.Solid;
Font.Size = FontUnit.Point(10);
Width = Unit.Pixel(90);
if (String.IsNullOrEmpty(Attributes["style"])) this.Attributes.Add("style", "border-bottom-width:1px;");
}
/// <summary>ÒÑÖØÔØ¡£</summary>
/// <param name="e"></param>
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
// УÑé½Å±¾
this.Attributes.Add("onkeypress", "return ValidIP();");
this.Attributes.Add("onblur", "return ValidIP2();");
this.Page.ClientScript.RegisterClientScriptResource(typeof(NumberBox), "XControl.TextBox.Validator.js");
}
}
}
|