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.
202 lines
7.3 KiB
202 lines
7.3 KiB
1 year ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Text;
|
||
|
using System.Web;
|
||
|
using System.Web.UI;
|
||
|
using System.Web.UI.WebControls;
|
||
|
using System.Drawing;
|
||
|
using System.Web;
|
||
|
namespace WebBase
|
||
|
{
|
||
|
[DefaultProperty("Text")]
|
||
|
[ToolboxData("<{0}:TextboxEx runat=server></{0}:TextboxEx>")]
|
||
|
public class TextboxEx : TextBox
|
||
|
{
|
||
|
#region BackColorOff
|
||
|
private Color _colOff = Color.White;
|
||
|
[Category("��չ"), Description("The background color when the control loses focus")]
|
||
|
public Color BackColorOff
|
||
|
{
|
||
|
get { return _colOff; }
|
||
|
set { _colOff = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region BackColorOn
|
||
|
private Color _colOn = Color.FromArgb(255, 255, 225);
|
||
|
[Category("��չ"), Description("The background color when the control has the focus")]
|
||
|
public Color BackColorOn
|
||
|
{
|
||
|
get { return _colOn; }
|
||
|
set { _colOn = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region TextDivInterval
|
||
|
private int textDivInterval = 15;
|
||
|
[Category("��չ"), Description("����������ʾ��֮���ļ���")]
|
||
|
public int TextDivInterval
|
||
|
{
|
||
|
get { return textDivInterval; }
|
||
|
set { textDivInterval = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region DivWidth
|
||
|
private string divWidth = "400px";
|
||
|
[Category("��չ"), Description("��ʾ���Ŀ���")]
|
||
|
public string DivWidth
|
||
|
{
|
||
|
get { return divWidth; }
|
||
|
set { divWidth = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region DivText
|
||
|
private string divText = "";
|
||
|
[Category("��չ"), Description("��ʾ����Ĭ�ϵ�����")]
|
||
|
public string DivText
|
||
|
{
|
||
|
get { return divText; }
|
||
|
set { divText = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region FocusDivText
|
||
|
private string focusDivText = "";
|
||
|
[Category("��չ"), Description("������ʱ��ʾ������ʾ������")]
|
||
|
public string FocusDivText
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (focusDivText == "")
|
||
|
return divText;
|
||
|
else
|
||
|
return focusDivText;
|
||
|
}
|
||
|
set { focusDivText = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ErrorDivText
|
||
|
private string errorDivText = "";
|
||
|
[Category("��չ"), Description("��������������ʱ��ʾ������ʾ������")]
|
||
|
public string ErrorDivText
|
||
|
{
|
||
|
get { return errorDivText; }
|
||
|
set { errorDivText = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region SuccessDivText
|
||
|
private string successDivText = "";
|
||
|
[Category("��չ"), Description("�����������ɹ�ʱ��ʾ������ʾ������")]
|
||
|
public string SuccessDivText
|
||
|
{
|
||
|
get { return successDivText; }
|
||
|
set { successDivText = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region OnlyShowAlertDiv
|
||
|
private bool onlyShowAlertDiv = false;
|
||
|
[Category("��չ"), Description("ֻ����ʾ��ʾ��,����������ʾ,�����������ؼ�������ʹ��")]
|
||
|
public bool OnlyShowAlertDiv
|
||
|
{
|
||
|
get { return onlyShowAlertDiv; }
|
||
|
set { onlyShowAlertDiv = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region AjaxRegisterType
|
||
|
private string ajaxRegisterType = "";
|
||
|
[Category("��չ"), Description("Ajax��Ӧע��������,ͨ��ָ��ҳ����AjaxPro.Utility.RegisterTypeForAjax(typeof(name))�е�name")]
|
||
|
public string AjaxRegisterType
|
||
|
{
|
||
|
get { return ajaxRegisterType; }
|
||
|
set { ajaxRegisterType = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
#region AjaxMethod
|
||
|
private string ajaxMethod = "";
|
||
|
[Category("��չ"), Description("Ajax��Ӧ�ĺ���,ͨ��ָ��ҳ���б���AjaxPro.AjaxMethod()�ĺ���")]
|
||
|
public string AjaxMethod
|
||
|
{
|
||
|
get {
|
||
|
if (ajaxMethod == "")
|
||
|
ajaxMethod = "check" + ID;
|
||
|
return ajaxMethod; }
|
||
|
set { ajaxMethod = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
private string controlToCompare = "";
|
||
|
public string ControlToCompare
|
||
|
{
|
||
|
get { return controlToCompare; }
|
||
|
set { controlToCompare = value; }
|
||
|
}
|
||
|
|
||
|
protected override void Render(HtmlTextWriter writer)
|
||
|
{
|
||
|
if (ajaxRegisterType != "")
|
||
|
{
|
||
|
string str = " <script language=\"javascript\" type=\"text/javascript\">"
|
||
|
+ " function check" + ID + "(){"
|
||
|
+ " var name = document.getElementById(\"" + ClientID + "\").value;";
|
||
|
if (ControlToCompare != "")
|
||
|
str += " var compare = document.getElementById(\"" + ControlToCompare + "\").value;";
|
||
|
str += " " + ajaxRegisterType + "." + AjaxMethod + "(name,";
|
||
|
if (controlToCompare != "")
|
||
|
str += "compare,";
|
||
|
str += " check" + ID + "_Callback);"
|
||
|
+ " }"
|
||
|
+ " function check" + ID + "_Callback(res){ "
|
||
|
+ " if(res.value==\"OK\"){"
|
||
|
+ " document.getElementById(\"Div" + ID + "\").innerHTML = \"" + successDivText + "\";"
|
||
|
+ " document.getElementById(\"Div" + ID + "\").className = \"NullDiv\";"
|
||
|
+ " }"
|
||
|
+ " else if( res.value==\"ERR\"){"
|
||
|
+ " document.getElementById(\"Div" + ID + "\").innerHTML = \"" + ErrorDivText + "\";"
|
||
|
+ " document.getElementById(\"Div" + ID + "\").className = \"AlertDiv\";"
|
||
|
+ " }"
|
||
|
+ " else"
|
||
|
+ " {"
|
||
|
+ " document.getElementById(\"Div" + ID + "\").innerHTML = \"" + DivText + "\";"
|
||
|
+ " document.getElementById(\"Div" + ID + "\").className = \"NullDiv\";"
|
||
|
+ " }"
|
||
|
+ " }"
|
||
|
+ " </script>";
|
||
|
writer.Write(str);
|
||
|
}
|
||
|
|
||
|
string dw = ((divWidth != "") ? " width='" + divWidth + "' " : "");
|
||
|
writer.Write("<table cellpadding='0' cellspacing='0' border='0' class='NullTable'><tr><td align='left'>");
|
||
|
if (onlyShowAlertDiv == false)
|
||
|
base.Render(writer);
|
||
|
writer.Write("</td><td width='" + textDivInterval.ToString() + "' ></td><td " + dw + ">");
|
||
|
writer.Write("<div id='Div" + ID + "' class='NullDiv'" + dw + ">" + divText + "</div>");
|
||
|
writer.Write("<div id='FocusDiv" + ID + "' class='InfoDiv'" + dw + " style='display:none'>" + FocusDivText + "</div>");
|
||
|
writer.Write("</td></tr></table>");
|
||
|
}
|
||
|
|
||
|
protected override void AddAttributesToRender(HtmlTextWriter writer)
|
||
|
{
|
||
|
base.AddAttributesToRender(writer);
|
||
|
string foc = "Div" + ID + ".style.display='none';";
|
||
|
if (FocusDivText != "")
|
||
|
foc += "FocusDiv" + ID + ".style.display='block';";
|
||
|
writer.AddAttribute("onFocus", foc);
|
||
|
|
||
|
string blurText = divText;
|
||
|
if (successDivText != "")
|
||
|
blurText = successDivText;
|
||
|
string blur = " Div" + ID + ".style.display='block';FocusDiv" + ID + ".style.display='none';";
|
||
|
//if (AjaxObject != "")
|
||
|
blur += "check" + ID + "();";
|
||
|
writer.AddAttribute("onBlur", blur);
|
||
|
}
|
||
|
}
|
||
|
}
|