I have built some custom controls like buttons and radio buttons using extension methods like this one :
public static class Buttons
{
public static MvcHtmlString EditButton(this HtmlHelper html, string action,
object controller, bool state)
{
var url = new UrlHelper(html.ViewContext.RequestContext);
var builder = new TagBuilder("a");
builder.MergeAttribute("href", url.Action(action, controller));
builder.MergeAttribute("alt", "edit");
builder.MergeAttribute("title", "Edit");
if (state)
{
builder.AddCssClass("edit_active");
}
else
{
builder.AddCssClass("edit_inactive");
}
string anchorHtml = builder.ToString(TagRenderMode.Normal);
return MvcHtmlString.Create(anchorHtml);
}
}
As you can see, this class needs some CSS files. I want to create a DLL which contains all this stuff and which I can import and use in other projects.
Any ideas how can I do it ?
Thanks.
Maybe something interesting here
http://toreaurstad.blogspot.com/2011/09/simple-access-of-embedded-resources-in.html
But it’s not unusual, for that kind of things (I think to Telerik mvc components, for example), to have a zip folder containing the dll and the static stuff (css, js) apart.
You will need to copy that static stuff in each project, of course, but it might be better (and more modular : you can offer different css for your helpers, they can be “overriden”…)