📄 caisisinputcontrols.cs
字号:
set { showLabel = value; }
}
#endregion
public string LookupCode
{
get { return lookupCode; }
set { lookupCode = value; }
}
protected override void OnInit(EventArgs e)
{
if(LookupCode != null && LookupCode.Length > 0)
{
try
{
PageUtil.FillLkpDropDown(this, LookupCode);
}
catch (System.ArgumentOutOfRangeException)
{
// ideally, this should be caught in PageUtil
}
}
if(FieldLabel != null && FieldLabel.Length > 0)
{
inputFieldLabel = new Label();
inputFieldLabel.Text = FieldLabel + " ";
}
}
protected override void Render(HtmlTextWriter w)
{
if(showLabel && FieldLabel != null && FieldLabel.Length > 0)
{
inputFieldLabel.RenderControl(w);
}
base.Render(w);
}
}
[DefaultProperty("Text"), ToolboxData("<{0}:CaisisComboBox runat=server></{0}:CaisisComboBox>")]
public class CaisisComboBox : ComboBox, ICaisisInputControl
{
public CaisisComboBox() : base()
{
showLabel = true;
}
#region private members
private string table;
private string field;
private string fieldLabel;
private bool required;
private string lookupCode;
private bool showHelpBubble;
private bool showLabel;
private string helpDescription;
#endregion
#region protected members
protected Label inputFieldLabel;
#endregion
#region Properties required to implement ICaisisInputControl
public string Table
{
get { return table; }
set { table = value; }
}
public string Field
{
get { return field; }
set { field = value; }
}
public string FieldLabel
{
get { return fieldLabel; }
set { fieldLabel = value; }
}
public bool Required
{
get { return required; }
set { required = value; }
}
public bool ShowHelpBubble
{
get { return showHelpBubble; }
set { showHelpBubble = value; }
}
public string HelpDescription
{
get { return helpDescription; }
set { helpDescription = value; }
}
public bool ShowLabel
{
get { return showLabel; }
set { showLabel = value; }
}
#endregion
#region additional Properties
public string LookupCode
{
get { return lookupCode; }
set { lookupCode = value; }
}
#endregion
protected override void OnInit(EventArgs e)
{
if(LookupCode != null && LookupCode.Length > 0)
{
Page.RegisterClientScriptBlock(LookupCode, PageUtil.FillComboDropDown(this.RefBy, LookupCode));
}
if(FieldLabel != null && FieldLabel.Length > 0)
{
inputFieldLabel = new Label();
inputFieldLabel.Text = FieldLabel + " ";
}
}
protected override void Render(HtmlTextWriter w)
{
if(showLabel && FieldLabel != null && FieldLabel.Length > 0)
{
inputFieldLabel.RenderControl(w);
}
base.Render(w);
}
}
// has not been tested anywhere. radio button list currenty used in eforms
[DefaultProperty("Text"), ToolboxData("<{0}:CaisisRadioButton runat=server></{0}:CaisisRadioButton>")]
public class CaisisRadioButton : RadioButton, ICaisisInputControl
{
#region private members
private string table;
private string field;
private string fieldLabel;
private bool required;
private bool showHelpBubble;
private bool showLabel;
private string helpDescription;
#endregion
#region protected members
protected Label inputFieldLabel;
#endregion
#region Properties required to implement ICaisisInputControl
public string Table
{
get { return table; }
set { table = value; }
}
public string Field
{
get { return field; }
set { field = value; }
}
public string FieldLabel
{
get { return fieldLabel; }
set { fieldLabel = value; }
}
public bool Required
{
get { return required; }
set { required = value; }
}
public bool ShowHelpBubble
{
get { return showHelpBubble; }
set { showHelpBubble = value; }
}
public string HelpDescription
{
get { return helpDescription; }
set { helpDescription = value; }
}
public bool ShowLabel
{
get { return showLabel; }
set { showLabel = value; }
}
#endregion
public CaisisRadioButton() : base()
{
showLabel = true;
}
public void AddClientSideEventHandler(string eventName, string script)
{
if(eventName != "" && script != "")
{
base.Attributes.Add(eventName, script);
}
}
protected override void OnInit(EventArgs e)
{
if(FieldLabel != null && FieldLabel.Length > 0)
{
inputFieldLabel = new Label();
inputFieldLabel.Text = FieldLabel + " ";
}
base.OnInit(e);
}
protected override void Render(HtmlTextWriter w)
{
if(showLabel && FieldLabel != null && FieldLabel.Length > 0)
{
inputFieldLabel.RenderControl(w);
}
base.Render(w);
}
}
[DefaultProperty("Text"), ToolboxData("<{0}:CaisisRadioButtonList runat=server></{0}:CaisisRadioButtonList>")]
public class CaisisRadioButtonList : RadioButtonList, ICaisisInputControl
{
#region private members
private string table;
private string field;
private string fieldLabel;
private bool required;
private bool showHelpBubble;
private bool showLabel;
private string helpDescription;
private string _value;
private NameValueCollection customAtts;
#endregion
public CaisisRadioButtonList() : base()
{
customAtts = new NameValueCollection();
showLabel = true;
}
#region Properties required to implement ICaisisInputControl
public string Table
{
get { return table; }
set { table = value; }
}
public string Field
{
get { return field; }
set { field = value; }
}
public string FieldLabel
{
get { return fieldLabel; }
set { fieldLabel = value; }
}
public bool Required
{
get { return required; }
set { required = value; }
}
public bool ShowHelpBubble
{
get { return showHelpBubble; }
set { showHelpBubble = value; }
}
public string HelpDescription
{
get { return helpDescription; }
set { helpDescription = value; }
}
public bool ShowLabel
{
get { return showLabel; }
set { showLabel = value; }
}
#endregion
#region additional Properties
public string Value
{
get { return _value; }
set { _value = value; }
}
#endregion
public void AddClientSideEventHandler(string eventName, string script)
{
if(eventName != "" && script != "")
{
customAtts.Add(eventName, script);
}
}
protected override void Render(HtmlTextWriter writer)
{
_CustomHtmlTextWriter _writer = new _CustomHtmlTextWriter(writer, customAtts);
base.Render(_writer);
}
}
[DefaultProperty("Text"), ToolboxData("<{0}:CaisisCheckBox runat=server></{0}:CaisisCheckBox>")]
public class CaisisCheckBox : CheckBox, ICaisisInputControl
{
public CaisisCheckBox() : base()
{
showLabel = true;
}
protected Label inputFieldLabel;
#region private members
private string table;
private string field;
private string fieldLabel;
private bool required;
private bool showHelpBubble;
private bool showLabel;
private string helpDescription;
//private string _value;
#endregion
#region Properties required to implement ICaisisInputControl
public string Table
{
get { return table; }
set { table = value; }
}
public string Field
{
get { return field; }
set { field = value; }
}
public string FieldLabel
{
get { return fieldLabel; }
set { fieldLabel = value; }
}
public bool Required
{
get { return required; }
set { required = value; }
}
public bool ShowHelpBubble
{
get { return showHelpBubble; }
set { showHelpBubble = value; }
}
public string HelpDescription
{
get { return helpDescription; }
set { helpDescription = value; }
}
public bool ShowLabel
{
get { return showLabel; }
set { showLabel = value; }
}
#endregion
public void AddClientSideEventHandler(string eventName, string script)
{
if(eventName != "" && script != "")
{
base.Attributes.Add(eventName, script);
}
}
protected override void OnInit(EventArgs e)
{
if(FieldLabel != null && FieldLabel.Length > 0)
{
inputFieldLabel = new Label();
inputFieldLabel.Text = FieldLabel + " ";
}
}
protected override void Render(HtmlTextWriter w)
{
if(showLabel && FieldLabel != null && FieldLabel.Length > 0)
{
inputFieldLabel.RenderControl(w);
}
base.Render(w);
}
}
#region utility classes
internal class _CustomHtmlTextWriter : HtmlTextWriter
{
private NameValueCollection atts;
internal _CustomHtmlTextWriter(TextWriter writer, NameValueCollection customAttributes) : base(writer)
{
atts = customAttributes;
}
public override void RenderBeginTag(HtmlTextWriterTag tagKey)
{
if (base.IsAttributeDefined(HtmlTextWriterAttribute.Type))
{
foreach (string k in atts.Keys)
{
base.AddAttribute(k, atts[k]);
}
}
base.RenderBeginTag(tagKey);
}
}
#endregion
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -