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.
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).