I have a problem. I'm trying to loop through a form and list it's id. The problem is when I use the code below it doesn't get into the form and list it's elements. It lists the elements of the body of the document which one of them is the Form it self. How do I go a layer deeper and get into the form. All the code below lists in five elements the "Form1"(The form itself is one of the lines it writes. How do I get in deeper. Also how I get a field value if I wanted.
For Each ctl In controls
Response.Write(ctl.id & "<br>")
Next ctl
To list the controls in your form, you could try something like this:
Dim form1 As HtmlForm = FindControl("Form1")
For Each ctl In form1.Controls
Response.Write(ctl.ID & "<br>")
Next ctl
You could use a little recursion to find all the controls in the form, and all the child controls of those form controls. The method would look similar to the example inthis article.
0 comments:
Post a Comment