Click here to Skip to main content
15,894,180 members
Articles / Programming Languages / C#

View, View Controller, Model Controller, Model (VVCMCM) Pattern

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
18 Mar 2012CPOL11 min read 18.7K   200   16  
The MVC Pattern was first conceptualized assuming all the three actors were present at one place. Since Web Applications have both a client and a server this needs to be applied differently without technology bias.
var Core =
{
    ModelControllerUrl: 'ModelController.rspx',
    
    CreateQueryString: function()
    {
        var key = '';
        var value = '';
        var queryString = '?';
        var keyValueLength = 0;

        keyValueLength = arguments.length;

        //since this is a name value pair check if this is an even number
        if (keyValueLength % 2 != 0)
        {
            //TODO implement try catch throw logic
            alert('Error in creating Query String');
        }
        else
        {

            for (var counter = 0; counter < keyValueLength; counter++)
            {
                //the first argument is the key
                if (counter % 2 == 0)
                {
                    key = arguments[counter];
                    queryString += key + '=';
                }
                //second argument is the value
                else
                {
                    //escape the value as it may contain special characters
                    value = escape(arguments[counter]);
                    queryString += value;
                    //do not add the & at the end of the query string
                    if (counter < keyValueLength - 1)
                    {
                        queryString += '&';
                    }
                }

            }
            return queryString;
        }
    }
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Riversand Technologies Inc
India India
Head of Engineering at Riversand Technologies Inc.

Comments and Discussions