SIGN UP MEMBER LOGIN:    
ARTICLE

How to add reusable codes in Visual Studio Toolbox

Posted by Suthish Nair Articles | Visual Studio 2010 February 26, 2011
This article shows how to use the Visual Studio Toolbox to make reusable code available to any project.
Reader Level:

This article shows how to use the Visual Studio Toolbox to make reusable code available to any project.

Introduction

What do we do when we want to use a common set of logic code snippets in every page of a project? 
Usually we create a class library, create a .dll file or add a class file, create it and reference it from there. 
Another important and cool way which can be used in Visual Studio is to add or use code snippets 
into Toolbox tabs. Then later just drag and drop the item into your project page.


Lets' Start

In my project, I wanted to use code snippets shown below in multiple pages. This a simple method which returns a string type. 

I don't want to copy and paste or create a separate class file or a .dll file etc.. 

So, how will I use this code snippet on other pages?

public string hello() { return "www.c-sharpcorner.com"; }

It's simple; just select the method then drag and drop into the Toolbox tabs and a new item gets created. 

This item can be renamed, deleted or added with others like it.


1.jpg


This is another cool feature provided in Visual Studio, great!

Note: For every Visual Studio version you need to add this functionality everytime.


Conclusion

Hope this feature helps you in your daily coding ways. Post your comments.
 

Login to add your contents and source code to this article
share this article :
post comment
 

Great one!!!

Posted by Amol Apr 16, 2012

Nice Article:-)

Posted by Vijai Anand Feb 27, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor