DT 的数据字典
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

58 lines
1.5 KiB

using System;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace Sp.Web.UI
{
[DefaultProperty( "BackColorOn" ),
ToolboxData( "<{0}:TextboxEx runat=\"server\" SkinID=\"TextBoxEx\"></{0}:TextboxEx>" )]
public class TextboxEx : System.Web.UI.WebControls.TextBox
{
private Color _colOff = Color.White;
[Category( "Appearance" ), Description( "The background color when the control loses focus" )]
public Color BackColorOff
{
get{return _colOff; }
set{_colOff = value;}
}
private Color _colOn = Color.WhiteSmoke;
[Category( "Appearance" ), Description( "The background color when the control has the focus" )]
public Color BackColorOn
{
get{return _colOn; }
set{_colOn = value;}
}
protected override void AddAttributesToRender( HtmlTextWriter writer )
{
base.AddAttributesToRender(writer);
if( inDesignMode() || System.Web.HttpContext.Current.Request.Browser.Type.IndexOf( "IE" ) > -1 )
{
writer.AddAttribute( "onFocus", "JavaScript:this.style.backgroundColor='" + ColorTranslator.ToHtml( _colOn ) + "';" );
if( _colOff.Equals( Color.Empty ) )
{
_colOff = this.BackColor;
}
writer.AddAttribute( "onBlur", "JavaScript:this.style.backgroundColor='" + ColorTranslator.ToHtml( _colOff ) + "';" );
}
}
private bool inDesignMode()
{
bool blnOut = false;
if( object.ReferenceEquals( System.Web.HttpContext.Current, null ) )
{
blnOut = true;
}
else
{
blnOut = false;
}
return blnOut;
}
}
}