What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 13420 |  Welcome, Guest!   Register  Login
Home > Articles > Visual Studio 2010/12 > Visual Studio 2012 Features – Extract To User Control

Visual Studio 2012 Features – Extract To User Control

Article posted by Ambily.Raj on 9/4/2012 | Views: 3417 | Category: Visual Studio 2010/12 | Level: Beginner | Points: 250 red flag


Visual Studio 2012 introduces another great feature for creating a user control out of the existing code. Till now we used to create different User controls and use it in main page. Now, with the introduction of Visual Studio 2012, we are developing the pages and generate the User controls from the existing page design.

For our sample, I used the default ASP.Net web application created by the Visual Studio. The Default.aspx page looks like the below. 

 

 
Let us create our new User Control from the ordered list specified in the Default.aspx. Select the Code Snippet and right click to open the Context Menu.    



From the Context Menu, select “Extract to User Control” option. This will open the “Save as” window, where we need to specify the User Control name and select OK.

 

Now, Visual Studio will create the new “MyUserControl” user control and modify the Default.aspx page to utilize the same.   

MyUserControl is generated using the selected ordered list code as shown below.


Notice the changes in the Default.aspx page. Register tag for registering the user control is added on top of the page. Selected code snippet [in our case ordered list code] is replaced by the user control declaration.


 
Note: Visual Studio will copy only the designer code; it won’t copy the corresponding code behind code like the event handlers associated with the code snippet. 

Conclusion

Visual Studio 2012 introduced many new features to help developers to improve their productivity. New “Extract to user Control” feature help the developer to create a user control out of an existing code snippet.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Ambily KK

Experience:9 year(s)
Home page:http://ambilykk.com/
Member since:Tuesday, May 18, 2010
Level:Silver
Status: [Member] [Microsoft_MVP] [MVP]
Biography:I have over 9 years of experience working on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Office Open XML, Azure, Visual Studio 2010. Technology adoption and learning is my key strength and technology sharing is my passion.
>> Write Response - Respond to this post and get points
Related Posts

In this article we will learn Page Navigation without using Navigator.js and passing value between two pages using using Session, using Roaming DataStore and using ApplicationDataCompositeValue in Metro Style Apps

Visual Studio 2012 introduced a new feature called SQL Server Object Explorer. In earlier versions of Visual Studio, we have Server Explorer, which opens up a particular connection and work with a single database data. Now with the new SQL Server Object Explorer, we are able to manipulate multiple databases from a database server.

In this article, I am going to share some shortcuts of Visual Studio. Hope this will be helpful.

In my previous article on data driven approach in coded UI, we have discussed about how to use the CSV files and Xml files as the dataSource.

Visual Studio 2010 Productivity Power Tool is a set of extensions for Visual Studio 2010 Professional and above versions which actually improves productivity of developers. In this Tips & Trick, I will show you one nice extension behavior named “Interactive Tooltip”, which will make your development life easier.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 8:31:22 AM