摘要:[asp.net] code_behind抓取所有的欄位
''' <summary> ''' 設定所有textbox的寬度 ''' </summary> ''' <param name="intWidth"></param> ''' <remarks></remarks> Public Sub SetAllColWidth(ByVal collect As ControlCollection, ByVal intWidth As Integer) For Each ctl As Control In collect If ctl.GetType.ToString = "System.Web.UI.WebControls.TextBox" Then Dim txt As System.Web.UI.WebControls.TextBox = ctl.FindControl(ctl.ID) txt.Width = Unit.Pixel(intWidth) End If SetAllColWidth(ctl.Controls, intWidth) Next End Sub
實際使用方式: SetAllColWidth(OOXX.Controls, 80)
參考文章