Using the Extract to User Control feature

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.

Getting ready

In order to use this recipe you should have Visual Studio 2012.

How to do it...

Here we are going to show how to easily generate a user control from a section of code in our web page.

  1. Open our previous ASP.NET application or create a new one.
  2. If you created a new application, add a control and customize it to your liking.
  3. Open the Site.Master page.
  4. Go to the div body and select the <section> element surrounding it.
  5. Right-click on the selected code and click on the Extract to User Control option.
  6. On the Save as dialog, assign the ...

Get Microsoft .NET Framework 4.5 Quickstart Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.