I have several different types of forms and controls on a page. How do I loop through all the TextBoxes and DropDownLists and display their respective Value/Text. I tried this, but it doesn't work:
foreach (Control c in Page.FindControl("form").Controls)
if( c is WebControl ) Response.Write(( (WebControl) c ).Text);
else if( c is HtmlControl ) Response.Write(( (HtmlControl) c ).Text);
I get the error "'System.Web.UI.WebControls.WebControl' does not contain a definition for 'Text'". How can I reference the Text value of a TextBox control and the Value of a DropDownList?