增加控件属性,编译后没用了,请问各位为什么?
TextBox.cs如下
用的Anthem的textbox,因为前段时间看到网上有个validation直接用class属性就可以进行验证,于是也加上了个Class属性
public class TextBox : ASP.TextBox, IUpdatableControl
{
private string classAttributes = " ";
[BrowsableAttribute(true)]
[DescriptionAttribute( "输入需要验证的内容 ")]
[DefaultValueAttribute( " ")]
[CategoryAttribute( "Appearance ")]
public virtual string Class
{
get { return this.classAttributes; }
set { this.classAttributes = value; }
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
AddScriptAttribute(
this,
"onchange ",
string.Format(
"AnthemTextBox_TextChanged(this, '{0} ', true, true); ",
UniqueID
)
);
base.AddAttributesToRender(writer);
}
aspx这样写的:
<cc1:TextBox id= "txtCustomerCode " Class= "Required " />
看上去似乎没问题,可编译后的Html变成这样:
<input name= "txtCustomerCode " type= "text " id= "txtCustomerCode " onchange= "AnthemTextBox_TextChanged(this, 'txtCustomerCode ', true, true); " />
class属性没了,盼高手解答,谢谢.
------解决方案--------------------onchange= "AnthemTextBox_TextChanged(this, 'txtCustomerCode ', true, true); "这个不是吗?