R
Randy
I'm trying to recurse the controls on a web page and insert some data
about the controls into a database but I get a StackOverflowException
before a counter I set for debugging purposes even increments one time.
Here's the button code:
Protected Sub btnGetCtrls_Click(ByVal sender As Object, ByVal e As
EventArgs) _
Handles btnGetCtrls.Click
Dim strFormID As String
ControlAdapter.Fill(ControlTable) 'Probably not necessary
strFormID = Page.Form.ID 'Gets the ASP form ID to use for each record
GetControlInfoRecurse(Page, strFormID)
End Sub
Here's the function code:
Public Sub GetControlInfoRecurse(ByVal oControl As
System.Web.UI.Control, _
ByVal sFrmID As String)
Dim oChildControl As Control
Dim sType As String
Dim strSEM As String
Dim l As Long 'For debugging
'We are only interested in certain control types
'so test for those
sType = oControl.GetType().ToString()
If sType = "checkbox" Or sType = "select-one" _
Or sType = "radio" Or sType = "textbox" Or sType = "text" _
Then
Try
ControlAdapter.InsertQuery(oControl.ID, sFrmID, _
oControl.GetType().ToString())
Catch ex As Exception
strSEM = ex.Message
End Try
End If
l += l
For Each oChildControl In oControl.Controls
GetControlInfoRecurse(oControl, sFrmID)
Next
End Sub
Eventually, I want to turn this into a user control so I can record the
relevant controls on each of several web pages in an application.
The logic seems straight forward enough: From the button, I initially
pass the Page to the recursive function. First things first, I ought to
get a DB record of the Page itself. I know this part works because I
tested it before I put the recursive part in. When I put the recursive
part in, however, I don't even get the Page DB record before the
StackOverflowException happens. This seems odd -- is VS anticipating
that there might be a stack overflow. In any event, the recursion seems
very straight forward. For each control in the Page.Controls
collection, call the recursion again. Where is this unbounded?
Heeellllpppp!
Thanks.
Randy
about the controls into a database but I get a StackOverflowException
before a counter I set for debugging purposes even increments one time.
Here's the button code:
Protected Sub btnGetCtrls_Click(ByVal sender As Object, ByVal e As
EventArgs) _
Handles btnGetCtrls.Click
Dim strFormID As String
ControlAdapter.Fill(ControlTable) 'Probably not necessary
strFormID = Page.Form.ID 'Gets the ASP form ID to use for each record
GetControlInfoRecurse(Page, strFormID)
End Sub
Here's the function code:
Public Sub GetControlInfoRecurse(ByVal oControl As
System.Web.UI.Control, _
ByVal sFrmID As String)
Dim oChildControl As Control
Dim sType As String
Dim strSEM As String
Dim l As Long 'For debugging
'We are only interested in certain control types
'so test for those
sType = oControl.GetType().ToString()
If sType = "checkbox" Or sType = "select-one" _
Or sType = "radio" Or sType = "textbox" Or sType = "text" _
Then
Try
ControlAdapter.InsertQuery(oControl.ID, sFrmID, _
oControl.GetType().ToString())
Catch ex As Exception
strSEM = ex.Message
End Try
End If
l += l
For Each oChildControl In oControl.Controls
GetControlInfoRecurse(oControl, sFrmID)
Next
End Sub
Eventually, I want to turn this into a user control so I can record the
relevant controls on each of several web pages in an application.
The logic seems straight forward enough: From the button, I initially
pass the Page to the recursive function. First things first, I ought to
get a DB record of the Page itself. I know this part works because I
tested it before I put the recursive part in. When I put the recursive
part in, however, I don't even get the Page DB record before the
StackOverflowException happens. This seems odd -- is VS anticipating
that there might be a stack overflow. In any event, the recursion seems
very straight forward. For each control in the Page.Controls
collection, call the recursion again. Where is this unbounded?
Heeellllpppp!
Thanks.
Randy