【发布时间】:2012-07-07 03:07:32
【问题描述】:
我正在从数据库模式构建一大堆不同的控件。 当我在后面的代码中运行控件时,我想将控件和样式(作为数据库中的字符串......例如“颜色:白色;宽度:50 像素;高度:10 像素;”)传递给重新- 可用的功能。
这就是我认为我应该这样做的方式:
Sub AddStylesToControl(ByRef ctrl As Control, Styles As String)
'split styles string by semi colon
Dim StyleArr() As String
Dim count As Integer
StyleArr = Styles.Split(";")
For count = 0 To StyleArr.Length - 1
'//ctrl.Attributes.Add("style", "color: red;")
ctrl.Attributes.Add("style", StyleArr(count))
Next
End Sub
不幸的是,在 "ctrl.Attributes.Add("style", StyleArr(count))" 行我收到一个错误: “属性”不是“system.web.ui.control”的成员 我理解错误的含义,但有人知道解决这个问题的方法吗?
非常感谢, 斯科特
【问题讨论】:
标签: asp.net vb.net attributes styles