January 22, 2010
MVC Helper-Helper
Haven’t done this blogging thing for a while. I’ll throw up some code that helps with MVC helpers that I just made and thought was Neat-O.
public enum TagType {Script,CSS}
public static class QuickTag {
public static TagBuilder GetTag(TagType tagType) {
TagBuilder builder;
switch (tagType) {
case TagType.Script:
builder = new TagBuilder("script");
builder.MergeAttribute("type", "text/javascript");
break;
case TagType.CSS:
builder = new TagBuilder("link");
builder.MergeAttribute("rel", "stylesheet");
builder.MergeAttribute("type", "text/css");
break;
}
return builder;
}