Extract to User Control in Visual Studio 11
Join the DZone community and get the full member experience.Join For Free
I have been playing with Visual Studio 11 beta recently and everyday I am amazed with new features of it. Today I have found one more very useful feature Extract to User Control feature.
In large projects, we are having large pages and its always good to user control(.ascx) but sometimes we are so lazy to create user controls and we remain with the whole page and even we can’t reuse that code. In similar kind of situation ‘Extract to user control’ can be quite useful. Suppose we have long HTML mark up and we need to convert one div to user control and then we can do it very easily with Visual Studio 11 beta Extract to User Control feature.
You just need to select code you want there in user control and then you need to right click and click ‘Extract to User Control’ like below.
And once you click on ‘Extract to User Control’ It will ask to save your user control with save dialog like following.
Once you click ok a new user control will be like following.
And now your mark up in default.aspx page will look like following.
So it will do all this things automatically. It’s a really cool feature and will make our life more easy. That’s it for now. Hope you like it. Stay tuned for more updates. Till then happy programming!!
Published at DZone with permission of Jalpesh Vadgama, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.