Mehdi-
My previous statement wasn't entirely correct. Literal text on the page can, as you have found, be accessed thru the controls collection. However, a specific tag is not accessible as a useful instance of an object on the server side. Sure, you can access the literal HTML. But then you'll need to handle all the parsing of a particular tag yourself. It's much easier to let .NET handle those details if you just want to modify some tag's attributes.
If you iterate thru all the controls in the Page.Controls collection, I think you'll find that you will get 3 controls:
1) A LiteralControl (or ResourceBasedLiteralControl) which is everything from "<html>" up to but not including "<form..."
2) A HtmlForm control (which is the form from "<form..." to "</form>")
3) A LiteralControl which is everything from but not including "</form>" to the end of the aspx (usually "</html>").
If you try to access these controls, you will get a cast error when you hit the HtmlForm control. I'm not sure how your test can be reporting that they are all literals.
|