关于ASP.net控件数组使用的问题
For i = 1 To 10txt = CType(pantz.FindControl("txt" & i), TextBox)
txt.Text = 0
AddHandler txt.TextChanged, AddressOf Txtc_Changed
Next
在页面加载事件里给10个文本框赋初值为0,并添加事件,但是在后面的事件里要这样写才能执行。
Public Sub Txtc_Changed(ByVal Sender As Object, ByVal e As System.EventArgs) Handles txt4.TextChanged, txt5.TextChanged, txt6.TextChanged, txt7.TextChanged, txt8.TextChanged, txt9.TextChanged, txt10.TextChanged
..............
end sub
可不可以不用每个控件都写上,有什么更好的办法吗? --------------------编程问答-------------------- For i = 1 To 10
txt = CType(pantz.FindControl("txt" & i), TextBox)
txt.Text = 0
AddHandler txt.TextChanged, AddressOf Txtc_Changed
Next
Public Sub Txtc_Changed(ByVal Sender As Object, ByVal e As System.EventArgs)
dim txt as TextBox = DirectCast(sender, TextBox)
'...
end Sub
补充:.NET技术 , ASP.NET