I've got a page that (though part of an application) is stand-alone in that when a user is finished with the page and submits the information it saves the data, and returns to its original state. It's got 56 radio buttons (in pairs), 31 textboxes, and 5 dropdownlists. When the user is finished modifying the controls and clicks the "Submit" button, I'll save the data and then do one of two things. Reset the page using a function, or do a Server.Transfer to the same page. Here's the code I'm using to "reset" the page.
Considering efficiency of running this code versus loading a new page (what Server.Transfer would basically be doing) which one is more efficient? Thanks, and have a great day.
Code:
...
For Each ctlCurrent As Control In Me.Controls
ClearControls(ctlCurrent)
Next
...
Private Sub ClearControls(ByRef controlToClear As Control)
Dim rdoCurrent As RadioButton
Dim txtCurrent As TextBox
Dim ddlCurrent As DropDownList
For Each ctlCurrent As Control In controlToClear.Controls
ClearControls(ctlCurrent)
Next
Select Case controlToClear.GetType.ToString
Case "System.Web.UI.WebControls.RadioButton"
rdoCurrent = controlToClear
If rdoCurrent.ID.Substring(controlToClear.ID.Length - 1) = "1" Then
rdoCurrent.Checked = True
Else
rdoCurrent.Checked = False
End If
Case "System.Web.UI.WebControls.TextBox"
txtCurrent = controlToClear
txtCurrent.Text = ""
Case "System.Web.UI.WebControls.DropDownList"
ddlCurrent = controlToClear
ddlCurrent.SelectedIndex = -1
End Select
End Sub