Hello,
I am looping through each control using the following to find a particular
control (strFindCtl = "tbxCompetitor" & strForLoop1 & "Product").
For ctrRow = 1 To 3
strForLoop1 = "0" & ctrRow
strFindCtl = "tbxCompetitor" & strForLoop1 & "Product"
For Each ctlMaster As Control In Page.Controls ' Page
If TypeOf ctlMaster Is MasterPage Then '
MasterPage
For Each ctlForm As Control In ctlMaster.Controls
If TypeOf ctlForm Is HtmlForm Then '
HtmlForm
For Each ctlContent As Control In ctlForm.Controls
If TypeOf ctlContent Is ContentPlaceHolder Then
'ContentPlaceHolder
For Each ctlChild As Control In ctlContent.Controls
If TypeOf ctlChild Is TextBox Then
If ctlChild.ID = strFindCtl Then strSubmitter &=
CType(ctlChild, TextBox).Text & ", "
End If
Next
End If
Next
End If
Next
End If
Next
Next
Based on the article
(http://dotnetjunkies.com/WebLog/jpal...01/23919.aspx), I
am trying to follow the format for the following in order to reduce my code:
(MyUserControl)Page.Controls[0].FindControl(ā€¯ucMyUserControlā€¯);
However, when I use the following:
Dim ctlSteven As Control =
Page.Controls(0).FindControl("tbxCompetitor01Produ ct")
Response.Write(ctlSteven.ID)
I get the error:
I get the error: System.NullReferenceException: Object reference not set to
an instance of an object.
Any help with this would be appreciated.
--
Thanks in advance,
sck10