Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
In this video, let's drill into View State just a little bit and let's talk about exactly what View State is and in the next video, I'll show you a brief little demo about View State. Well View State is a really cool functionality, it's automatically implemented in ASP.NET, you don't have to do anything to turn it on, it just happens. Now you can do some other things to control it but by default it's going to be there. It is a Client Side State Solution and it's implemented on each individual control. So anytime you drag a control out of the Toolbox and onto your web form, View State is going to be there, it's going to be working on it. It is controlled by the Enable View State Property. It's on by Default, you can turn it off if you want to and also you will see that this is implemented at the page level as well. Alright. There is a View State Collection that is simply a collection of the list of values, all in one place and it's the list of all the values on all the controls on that page. Now if you'll look at a page and I'll show you this in the demo in the next video, you'll see that ASP.NET will write an Input Type out there, like we normally would see button or whatever but notice the type is hidden and the name you'll actually see the word View State and then you'll see some, it looks like gibberish or hieroglyphics or whatever you want to call it. But it's because they've encrypted the State Information for all the controls and data on the page and they've also compressed it and so there's all kind of cool things happening here but the bottom line is, these controls will remember what you put into them, between round trips to the server. So every request for the same page, now notice these two words down here for the same page will remember the values for each control, every time you request the same page from the server again. Which for us means PostBacks. So let's talk a little bit more about View State and then you're going to see something else called Control State. Well View State for a control can be turned off at the page level. Control State cannot be turned off at the page level. Notice the little difference there. I can have View State on and then somebody can come in here and turn it off at the page level and boom, I just lost it on my controls. But if I set Control State on and somebody turns it off at the page level, it still works on each individual control that's using Control State. Alright. Now what could possibly be a problem here? What are the disadvantages of using View State which is automatic to handle the problems of State of our controls on our web pages? First of all, it's designed for single page state, once I move to a separate page on the website, none of the controls on this first page get carried over to that next page. Okay. This only works for posting the exact same single page back and forth to the server. Alright. So this once solve our challenges in, like online commerce or any of that sort of thing. It also adds bytes to the Page Size and the Transport Size because think about it. If you've got 25 controls on a page, you've got to take all the data that's in each one of those controls, put it into this View State string, encrypt it and pass it back and forth. So this can first of all, effect the size of the page you're having to pull of the server and we want to keep that as quick as possible. It's also effecting the Transpost Size or the bandwidth that's being used on our network alright? It also consumes memory, because these pages have to be pulled into memory on the web server and on the Client Side and this whole issue of memory can become especially troublesome on mobile devices. Any kind of mobile device you use now, they're really cool, they're really slick but notice you don't have a whole lot of memory, especially RAM available on these mobile devices. Now it's not unusual now to see Smart phones and that sort of thing with 8 gigs and 16 and 32 gigabytes of storage space but if you dig into development on those devices, you find out a lot of times you've got 256 megabytes of memory that you can use or even less than that at any one time. So this can really start to become a problem and so memory really gets to be an issue on mobile devices with web development, so that's something that's going to have to be considered. So anyway, in the next video I'll do a quick little demo, and show you what View State looks like and how it works but again just understand the limitations, this is only for a single page and it can create some Page Size and Transport Size issues on this, especially in mobile development.
| Course: | Designing and Developing ASP.NET 4 Web Apps (Exam 70-519) |
| Author: | Mark Long |
| SKU: | 34292 |
| ISBN: | 978-1-61866-029-9 |
| Release Date: | 2011-12-31 |
| Duration: | 8.5 hrs / 108 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |