Shrt Dv Thts

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;
    }

1 note on how epic this is and comments
Post Notes
  1. tylerham posted this
blog comments powered by Disqus