Classic MVC

Classic MVC is an MVC framework written entirely in JScript for Microsoft's Classic ASP. Separation of concerns, controllers, partial views and more.

How does it work?
Classic MVC can be added to individual pages, leaving the rest of your website intact, if you wish.
Pages become controllers which expose code to the Classic MVC libraries (common includes). The libraries determine which action/view to render. View selection is based on filters (ie: GET/POST, authorization, etc) and URL (/Home.asp?/Index). Once a view is selected, a model may also be populated and the end result is rendered to the user.

This means that, for example can be mapped to different views, redirected or return raw JSON depending on the nature of the request in a clean, organized fashion.

What does code implemented using Classic MVC look like?

Say, if you would like to present a different page to the user depending on whether the request was made with GET or POST:
  "index": function() { 
      return classicmvc.view();
  "register": function() {
	var model = { someProperty: "someValue" };
	   //Return /views/register/RegisterGet.asp
	   addAction([classicmvc.filters.acceptVerbs("get"), classicmvc.filters.allowAnonymous], function() {
			return classicmvc.view("RegisterGet.asp", model);
	   //Return /views/register/RegisterPost.asp
	   addAction([classicmvc.filters.acceptVerbs("post"), classicmvc.filters.allowAnonymous], function() {
			return classicmvc.view("RegisterPost.asp",model);

This allows a powerful separation of concerns and a much cleaner implementation in Classic ASP for your code. The actual views do not include any references to outside code. No includes are necessary. Only presentation code will be contained in the view.
Classic MVC also provides HTML Helpers which function very similar to ASP.NET MVC helpers:
	<%=html.textBox("test", 32)%>
	<%=html.dropDownList("test", myList, { "style":"background-color:cyan;" })%>

Master/Layout Pages
Yes! Classic MVC supports "layouts" (like Web Forms "Master Pages" or MVC's "layout pages").

</html> individual page, can then define sections like the following:
<%classicmvc.section.add("head", function() { %>
      <script src="jquery.js"></script>
      <link href="/Main/Styles/Normalize.css" rel="stylesheet" />
      <link href="/Main/Styles/Main.css" rel="stylesheet" />
<% }); %>

Model Validation
Classic MVC support model validation using jquery.validate and the Microsoft MVC/AJAX JavaScript libraries bundled with ASP.NET MVC3.
<%=html.beginForm(function() {%>

     <%=html.textBoxFor("FirstName", function(m) { return m.FirstName })%>
     <%=html.validationMessageFor("FirstName", function(m) { return m.FirstName })%>

     <input type="submit" />
<% }); %>

Last edited Aug 18, 2012 at 7:09 PM by aikeru, version 9