Great thanks to you Danial
For other visitors who may need this code, here is the full code to iterate through the web form controls and getting the value of the found control. Other types of controls are also listed for you to test and print.
VB Code:
Dim i As Integer Dim x As string Dim txt As String Dim ct As Control For i = 0 To MyForm.Controls.Count - 1 ct = MyForm.Controls(i) x = ct.GetType.ToString Select Case x Case "System.Web.UI.WebControls.TextBox" txt = CType(ct, TextBox).Text Response.Write("TextBox value is: " & txt) Case "System.Web.UI.WebControls.DropDownList" txt = CType(ct, DropDownList).SelectedItem.Text Response.Write("DropDownList value is: " & txt) Case "System.Web.UI.WebControls.ListBox" txt = CType(ct, ListBox).SelectedItem.Text Response.Write("ListBox value is: " & txt) Case "System.Web.UI.WebControls.Button" txt = CType(ct, Button).Text Response.Write("Button value is: " & txt) Case "System.Web.UI.WebControls.RadioButton" Case "System.Web.UI.WebControls.CheckBox" Case "System.Web.UI.HtmlControls.HtmlInputCheckBox" Case "System.Web.UI.HtmlControls.HtmlInputButton" End Select Next
MrAli




Reply With Quote