WP TutorialLesson 18Free preview
WebPages Classes
This lesson is part of ASP · All levels
Summary
Web Pages allows you to create your own class in the App_Code folder to pack data and logic so that it doesn't pile up inside the page. A class contains a property as a data store and a method as a behavior, then the object is created on the page .cshtml. This separation makes the code more neat, reusable, and easy to test.
Key points
- The artificial class is placed in the App_Code folder with the .cs extension.
- Properties store object data, whereas methods define their actions.
- Objects are created with new NamaKelas() and then accessed through a point.
- The logic that was transferred to the classroom was easier to reuse on many pages.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.