我正在尝试向网页控件添加属性.
TextBox txt=new TextBox();
txt.Attributes["Foo"]="Bar"
Run Code Online (Sandbox Code Playgroud)
我需要把它放在一个方法中,但我的问题是我不知道我将发送给它的是什么样的元素 - 也许输入可能是一个选择.本质上我需要这个方法,但是什么oControl呢?在VB中我曾经称之为object.
protected void SetAttrib(oControl){
oControl.Attributes["Foo"]="Bar"
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我想你想要WebControl:
protected void SetAttrib(WebControl oControl){
oControl.Attributes["Foo"]="Bar"
}
Run Code Online (Sandbox Code Playgroud)