Reputation: 13602
I am looking to create a widget that can be used with other solutions. The widget is a competition widget that can be placed in different parts of the site. What is the best way to do this? Should I create a new solution to hold this in?
Upvotes: 1
Views: 2513
Reputation: 100312
As opposite of some answers, you should create user controls with embedded resources.
It is complex to do it, but once you do you will be able to develop controls like RadControls
from Telerik.
If you open up their controls you will see that they are all embedded resources
on the Telerik.Web.UI.dll
.
Here is an old answer of mine that shows how to load the control and how to handle embedded resources (virtual path provider)
Unless you have a good reason to do so (like creating a generic control as a calendar, grid or something like that) don't go this way, it is dark, complex... But as you can see it might be worth it, Telerik.Web.UI
is the live example that this can work out.
Upvotes: 0
Reputation: 2932
It depends if you will be using it in other solutions really. If you are, then if might make more sense to create a new widgets solution with each widget in its own user control and compile it into an assembly.
Then you just reference that assembly and use it in your markup.
If your widget is only going to be used in a single solution then I wouldn't bother with the above. Just create a user control in the same solution.
Upvotes: 0
Reputation: 4281
Here is relatively simple tutorial on creating a custom WebControl:
Create ASP.NET Server Controls from Scratch
And here some more advanced example from MSDN:
Developing Custom ASP.NET Server Controls
Upvotes: 1
Reputation: 1840
You need to create a Web Control, not a User Control, if you want o use it in other projects. This question details the different control types, you may find it useful: What is the difference between UserControl, WebControl, RenderedControl and CompositeControl?
Upvotes: 1
Reputation: 33857
Create a new class library project (you can have it within your current solution if it suits) and create your server controls in there. You can then reference this library from whatever websites you need.
Upvotes: 1