Home
Username:
Password:
Microsoft ASP.NET 3.5 Tutorials

Next Level ASP.NET / No Code Behind Page

Subtitles of the Movie

Now this is probably as good a place as any in the course to show you something that is becoming more and more popular among ASP.NET developers and I just want to show it to you so that you'll see these out there in the real world and don't let them confuse you or throw you. They don't use the Code Behind page, and I've mentioned how we've got this Code Behind page back there. I'm going to create a new Web site here and I'm just going to put NoCodeBehind for an example to show you this and notice that when I bring this page up this Default page, if I drop a Button on this and double click it, right, it automatically takes me to a Code Behind page, well, I don't have to do that. If I go over to Solution Explorer and I right-click and say Add a New Item and I tell it to add a Web Form, notice right here: Place code in separate file. I can clear that and add my page and now I have a new page out here and it's called Default2.aspx and I want you to notice something. If I drag a button onto this page, I double-click that button to put my Event back there, notice it does not take me to a Code Behind page, it takes me to the Source Page and it puts a script tag up at the top just above the Head and it puts my Event Handler in there just like always and I can put my code in here. I can say, okay, when I click on that I want Button1.Text to change to Clicked. So I can come back out to Design and I can run this page and you're going to notice that when it runs it's the same as always. There's my page and when I click on this it comes back and it says Clicked. Nothing's different except I'm not using a Code Behind Page on this. If I double-click and jump to the back notice it just put a PageLoad in here. I can take that out, but here's my Button1.Clicked, so I can code, I can write all my code right here. Now a lot of people call this in-line and a lot of guys like this. They say it's less confusing. Everything's in one place. They can print this page out. They can see exactly what's going on. Down here notice on your button you have this onclick call, it points to up here. But I just wanted you to see this. You will see it among people out there. Some will treat you like you've got some sort of disease if you're still doing Code Behind Pages. Ignore those people unless they're signing your paycheck, but I just wanted you to see that you do have an option, Code Behind has been such an integral part of ASP.NET for so long for so many people, but it's really becoming popular not to do that and we may actually see the Code Behind Page go away in future versions, but for now you can choose to either have it or not have it. Just wanted you to be aware.

Tutorial Information

Course: Microsoft ASP.NET 3.5
Author: Mark Long
SKU: 34102
ISBN: 1-93633412-7
Release Date: 2010-03-24
Duration: 6 hrs / 69 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available