Click here to Skip to main content
15,860,972 members
Articles / Programming Languages / C#

MVC PLUS for MVC.NET 3.00

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
8 Aug 2012CC (ASA 3U)7 min read 21.3K   16   2
WebLights Component Library

Note: This framework is a framework that has 100% compatibility with standard MVC FOR SPRING in J2EE and MVC.NET 3.00 and is running on top of them and adds many capabilities which did not exist in this arena before.

I always disliked webforms because of its low quality of code and also the non web nature it had. Moreover, I liked C# but because of leaking of MVC architecture in this platform. I went to JAVA, whose library we are talking about also has a JAVA (MVC FOR SPRING) component Library but I would like to introduce C# and MVC.NET version as my favorite product.

The goals of this design were:

  1. An application like environment in the web
  2. Made a Real DB Centric System and less effort in manual coding for forms
  3. Low weight and high quality pages
  4. NEVER Use From IFrame or Popup Windows because of their behavior (which I did it with JavaScript SandBox means: all forms you load will load in the same DOM area and they will show in a DIV not an IFRAME)
  5. And many other goals; the most important was: a new and standard way for development specially I like to use META MODELS against Models because of Meta Models are have a much stronger concept.

This system is:

  • 100% full Ajax
  • No refresh required at all (I repeat again no refresh but you can redirect but also, no need to refresh the page at all)
  • Upto 5 times faster Page Load
  • And for the first time:
    • Java Script SandBox support Implemented in component Model (No need for Iframes at all!)
    • 100% DB centric System

Compare after we have done the job.

We wrote the same code for the same reason and we tested them in three different platforms. Here, you can see the results:

Image 1

As you see, MVC PLUS needs one third of MVC.NET and less than half of WebForms to spend it in development which means, less cost, more high quality code and exactly a cheaper and better product in code quality and overall.

Here, we compared these frameWorks in line of Rendering size which also means less Render Time in server side which is effective if you use SSL (less cost for application server and much faster data transfer):

Image 2

As you see, Average Forms rendered with MVC Plus have a size between 5 to 10 Kilobytes which is much less than other competitors, even less than half of their size in MVC.NET (Using Telerik Components).

Note: All tests passed in my friends' office, later I will publish the sample codes (these were a real product for business, so my friend might cut some parts of code).

Note that all tests was done for the similar form design in view and reason and scenario.

STANDARD MVC 3.00

In standard MVC, you have to write your models as below:

C#
public class Person{
  public string name {get ; set ; }
  public string FamilyName {get ; set ; }
}
public class ADDRESS{
  public string name {get ; set ; }
  public string FamilyName {get ; set ; }
}

Each view can support only up to one Model, for example, you can have only Person Model or address Model accessible.

In MVC PLUS

In MVC Plus, you have to declare your Models separated from Meta Models and Meta Models will be used in Controllers and Views:

First write your Models (which work as repository or DAL):

C#
public class Person:WLBaseModel {
  [PrimaryKey]
  public int PersonID;
  [stringLength (max:50)]
  [REQUIRED]
  public string name {get ; set ; }
  [REQUIRED]
  [stringLength (max:50)]
  public string FamilyName {get ; set ; }
}
public class ADDRESS:WLBaseModel {
  [PrimaryKey]
  public int addrssID {get ; set ;}
  [ForeignKey(Person)]
  public int PersonID {get ; set ;}
  [REQUIRED]
  [stringLength (max:50)]
  public string City {get ; set ; }
  [REQUIRED]
  [stringLength (max:65535)]
  public string Address {get ; set ; }
}

And then you have to declare your META MODELS as below:

C#
public class MetaModel :WLBaseMetaModel
{
  [ApplicationServerCache { timeOut:10}]
  public Person Person{get ; set ;}
  [ApplicationServerCache { timeOut:10}]
  public Address Address {get ; set ;}
}

In Standard MVC 3.00, you cannot have access to both models. In MVC PLUS And Meta Models, you can have many models in one Meta Model.

Views

We only support RAZOR in MVC.NET 3.00, so, other view engines are not supported by now and we don’t think we will support them later.

You can use META MODELS you declared in your View as below:

@Html.WLControlFor(m=>m.Person.Name)
@Html.WLControlFor(m=>m.Person.FamilyName)
@Html.WLControlFor(m=>m.Address.City)
@Html.WLControlFor(m=>m.Address.Addrsss)

All Model members will Be Connected to each other , Grids, Trees, Editors, checkboxes, Combos etc, I repeat this phrase that you have to separate concept of Models and Meta Models From Each other.

Here , you can see What I means in the upper lines:

Image 3

As you see, Tree and Editors are connected to each other.

But how it works? In brief we have an architecture like this , it was a complex architecture but we did it once to have a safe way of development:

Image 4

Later, I will introduce you how much it is hard to implement such a code in a heavy JavaScript and C# Library (mostly in architecture which was a hard to do)

Note that this is a huge and great architecture for WEB , maybe for first time??? (I don’t know! Just maybe), we did several new things to supply this abilities.

Batch Data Transfer

In standard MVC data transfer can send transfer a single record and you need to do many custom code for multiple records.

Hard For Development in most cases you want to transfer several records to/from Server.

In MVC, you can send / receive multiple records at once and we can name it Batch Transfer , it is useful for most cases of development.

As an extra advantage in architecture, MVC Plus have a two side (server/client) cache in both client and server which will guarantee:

You will receive a record or data only One Time.

You will receive only required records which are need to show them in client.

Image 5

You can set Model Behavior as Live.

Since data is changed in client and you change cursor position in client or modify client data, Client Will send Update or Inserted or Deleted item to Server

C#
Address.LiveData = true;

You can set Model Behavior as Offline.

You can send batch records , for example 10 modified records to server at once

Person.LiveData = false;

To handle batch or single records , you have triggers such as :

  • Beforeinsert
  • BeforeUpdate
  • BeforeSelect
  • BeforeDelete
  • BeforeChange
  • BeforeOtherCommands

And also you have:

  • Afterinsert
  • AfterUpdate
  • AfterSelect
  • AfterDelete
  • AfterChange
  • AfterOtherCommands

Master/Details

  • In MVC Plus, you can made Models are available in Meta Models as Master detail, but don’t worry, no need to do much of code you thing just you have to do it with few lines of code, You can connect two models as Master detail as below:

    C#
    Address.Master = Person;

    Or :

    C#
    [AutoConnectModels("*")]
    public class MetaModel {
                 … {Models …
    }

    No Need For Extra Code.

    Required Data for automatic actions will be provided through attributes Over model Properties:

    C#
    [PrimaryKey]
      public int addrssID {get ; set ;}
      [ForeignKey(Person)]
      public int PersonID {get ; set ;}

    Validation:

    Validations are will show beside of controls and client will show a message before send them to Application Server.

    Validation is very similar to standard MVC but you can have:

    1. RowValidation
    2. FieldValidation

    This is not required to do RowValidation most of the time, but also you can add it to client and server.

    By default, most of validations will be done automatically.

    A sample code would be:

    Required]
    [RangeOf(OnlyAlphabet)]
    [MaxMinLength(5,50)]
    public string  Name {get ; set ;}

    Or even:

    [Required]
    [Password(StrongPassord)]
    [MaxMinLength(5,32)]
    [EqualTo("confirmPassword"]
    Public string Password {get ; set ; }

    Also system will automatically validate type of model members in both client and server.

    Validations are will show beside of controls and client will show a message before send them to Application Server. You can set an special shape for them easily but by default they we have four different way of showing them: 1 – Before Post as Modal (DIV Modal not POPUP!) 2- in left top corner as tooltip when you are typing them 3- Custom Way 4- in Left or Right space of Edit Control

    Components

    Each Single Control Should have a FieldName, which is similar to Model’s Property name in application server, these are will be generated automatically by C# or J2EE components.

    Just leave your control simply in view:

    @Html.WLControlFor(m=>m.Address.Addrsss) 

    We have many component ready for this Framework:

    • Html.WLTextEditFor
    • Html.WLWebEditorFor
    • Html.WLDivEditFor
    • Html.WLDisplayfor
    • Html.WLTreefor
    • Html.WLCheckBoxFor
    • Html.WLComboBoxFor
    • Html.WLSpinEditFor
    • Html.WLAutoCompleteFor
    • Html.WLLookUpFor
    • Html.WLGridFor

    And more than 109 other READY TO USE components

    In pictures below you can see some pages are designed with this system , note that this tabs are not IFRAMES but they come from different sources and they are using from JAVASCRIPT SandBox Model, always you can run any JS Command From server side without refresh.

    MVC PLUS 2.00 now support TREE MODELS which are not exists before:

    • Tree Models are have two way, manual or Automatic which uses Recursive Model. No need for any special code.
    • Just Made Tree Property in Model Enabled:
    • Model.IsTree=True;
    • And then in view:
    • @Html.WLTreeFor(m=>m.Person)

    Ryan Samiee

    BCs and 16 years Professional Experience (since I had 14 years old I started working with companies as a professional developer) and 14 years experience in Component Development in Delphi and then WEB Components.

  • License

    This article, along with any associated source code and files, is licensed under The Creative Commons Attribution-Share Alike 3.0 Unported License


    Written By
    Iran (Islamic Republic of) Iran (Islamic Republic of)
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    QuestionOn what basis Pin
    Christian Graus20-Jan-14 17:35
    protectorChristian Graus20-Jan-14 17:35 
    QuestionWaiting for your questions. Pin
    Ryan Samiee8-Aug-12 18:28
    Ryan Samiee8-Aug-12 18:28 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.