Category Archives: MVC
In this post we will be setting up MongoDB in an MVC application. Before starting on it I expect that the audience has good knowledge of MongoDB.
MongoDb is a schema free, scalable, high performance document database. When we say schema less it blows mind of many SQL developers. Schema independent feature of MongoDB provides flexibility to the developer to develop the schema as they progress with the application.
A Web application is an application that can be hosted on a web server and can be accessed from any machine that lies in the intranet or internet which has the web browser to render and display the web pages in that application.
With the help of Visual studio 2012, the web application can be created by using two different templates provided. One is by using “New Website” template and another is by using “New Web Application” template. This document is basically to compare and contrast the features of using these templates.
How to Create a New Web Application Project:
- In Visual Studio, Select new “project “option from file menu as shown below:
Many times we come across a situation in MVC when we require two different Models in a strongly typed View. This need usually arise when we have a requirement to use properties of two different models in a single view.
Problem : Can we really have two or more models in a strongly typed View???
In MVC, there is no click event like(Button_Click) for buttons, action is used to handle the post action of the buttons.
(There are various ways for handling multiple submit buttons on the same form but the best two are below)
Method 1: Handle all Submit Buttons post in one Action:
Example: Suppose we have to perform some mathematical operation like (Add, Substract, Multiply, Divide) with 2 numeric values.
For this case, we will create a form and add 2 TextBoxes and 4 submit buttons for each opeartion (Add, Substract, Multiply and Divide).