Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 26th, 2004, 10:23 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old July 26th, 2004, 05:10 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

I changed my code
----------------------
foreach (object obj in Page.Controls)
{
 if(obj.GetType()==new HtmlForm().GetType())
 {
     foreach (object objfrm in ((HtmlForm )obj).Controls)
     {
     if(objfrm.GetType()==new Button().GetType())
        {
         ((Button)objfrm).Text="I've become so Numb.....LinkinPark";
         //change ......
        }
     }
 }
}
---------------------
any attempt for accessing HtmlForm control(It's InnerHtml property) results in a runtime error:
"Cannot get inner content of Form1 because the contents are not literal."
I don't know the cause of it exactly.
With lots of thanks to Peter.

--------------------------------------------
Mehdi
I'm waiting for your better idea.
 
Old July 27th, 2004, 02:42 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Whitstable, , United Kingdom.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Peter,

  sorry that was a typing error on my part. I had included the
  final %> part of the string but it still didn't like it.

  The full syntax I used was

onclick="sString='<%# DataBinder.Eval(Container.DataItem,"field1")%>';"

 It still gives the same error as above.






Similar Threads
Thread Thread Starter Forum Replies Last Post
datagrid command buttons CyberW ASP.NET 3.5 Basics 21 November 29th, 2008 04:02 PM
Using command buttons in Access kelljw Access VBA 10 July 5th, 2006 12:42 PM
Using command buttons in Access kelljw BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 July 4th, 2006 07:21 AM
Labels as command buttons RichMW Access VBA 0 February 18th, 2005 09:10 AM
Graphics For Command Buttons Teqlump Access 1 November 24th, 2004 11:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.