p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 (http://p2p.wrox.com/forumdisplay.php?f=389)
-   -   Chapter 8 Quick VB question (http://p2p.wrox.com/showthread.php?t=78465)

ChuckASP March 7th, 2010 01:29 PM

Chapter 8 Quick VB question
 
On page 284 in the NavigateURL property, _navigateUrl is defined as an Object and then 'cast' using CType as a String. Why can't _navigateUrl be defined as a String? Is it because ViewState is a property object an thus the object has to be cast as a String to return it?

Chuck

Imar March 7th, 2010 01:33 PM

Hi Chcuk,

Yes, that's correct. ViewState stores Objects which enables you to store any type of object in it (as long as it can be serialized). When you store it, you know you store, say, a string. So the underlying object is really a string, but exposed as an object (as ViewState only understands objects). In order to get it back as the type you're expecting, you need to cast it.

Hope this helps,

Imar


All times are GMT -4. The time now is 05:44 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.