From the course: ASP.NET Web Forms Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Understanding the code-behind files

Understanding the code-behind files - ASP.NET Tutorial

From the course: ASP.NET Web Forms Essential Training

Start my 1-month free trial

Understanding the code-behind files

- So next up, let's talk about code behind files. But before we do that, let's remove what we've added here so we don't have any code that will change what we are doing. And as I mentioned, the correlation between the CodeBehind files and the aspx, it's down here. It says that the CodeBehind files should be About.aspx.cs, and that we are going to inherit from the DemoApp.About class. So going back here, we see that already we have a Page_Load. And Page_Load will be automatically invoked when the page is getting loaded. At the end of this module, I'm going to go through the whole page life cycle where Page_Load would be mentioned as well. So, let's do something else in here. So we saw that we can add code on the aspx file. Now, there is one reason we would want to avoid this. Mainly because this would create the so called spaghetti code feeling. If I'm going in the aspx file and I'm adding the code that I need or that I want to have, it might create some problems in the future…

Contents