-
Book Overview & Buying
-
Table Of Contents
Microsoft .NET Framework 4.5 Quickstart Cookbook
By :
Modularizing is always a good idea to simplify code. With the Extract to User Control feature, we have a powerful tool that will help us with this refactoring functionality.
In order to use this recipe you should have Visual Studio 2012.
Here we are going to show how to easily generate a user control from a section of code in our web page.
Open our previous ASP.NET application or create a new one.
If you created a new application, add a control and customize it to your liking.
Open the Site.Master page.
Go to the div body and select the <section> element surrounding it.
Right-click on the selected code and click on the Extract to User Control option.

On the Save as dialog, assign the name ListOfCategories.ascx and click on the OK button.

Now we will need to move the GetBookCategories() method from the code, as the related methods are not moved.
We simply created a user control based on a section of our HTML...
Change the font size
Change margin width
Change background colour