Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 October 11th, 2009, 11:41 AM
epc epc is offline
Registered User
 
Join Date: Jul 2008
Posts: 7
Thanks: 4
Thanked 0 Times in 0 Posts
Default Chapter 8 User Controls: Try It Out Pages 283-286

For some reason I struggle with wrapping my head around a few concepts related to User Control coding. Particularily the Try It Out on pages 283-286. When I set NavigateURL for banner1 in the Code Behind of the AboutUs page why does this code not affect lnkVertical NavigateURL settings for the control on the MasterPage. My first thought is that the AboutUs.aspx viewstate relates only to the banner1 control defined there, but why does the NavigateURL code not affect the viewstate of the MasterPage sidebar user control settings.
 
Old October 11th, 2009, 11:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Each loaded User Control maintains its own state. As you've seen, ViewState contains the (encoded) values that are set by .NET or by your own code. However, it doesn't directly write to the __ViewState hidden field but writes and reads through the StateBag class. Internally, this class keeps track of which value belongs to which control instance. So, rather than storing with the following pseude code:

Banner.NavigateUrl = SomeValue

it does something like:

Parent + Banner.ID + NavigateUrl = SomeValue

This means the NavigateUrl can be stored in ViewState seperately for each Banner control you have somewhere in the Page hierarchy (e.g. in a master Page, a Page, a User Contro, and so on), even if they have the same ID (since they are located somewhere in the hierarchy, the "path" to them / their parent is unique.

Does this help?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
epc (October 12th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 8 in VB.NET page 283 jensam BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 August 19th, 2008 08:02 AM
Chapter 8: User Controls - Shows all banners VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 April 9th, 2008 03:45 PM
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
Redirecting User to different pages fletched PHP Databases 1 March 29th, 2004 04:38 PM





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