I am building an ASP.Net MVC 2 application for a client and it requires the ability for user to define views. On this website it shows how to do this - http://www.umbraworks.net/bl0g/rebuildall/2009/11/17/ASP_NET_MVC_and_virtual_views , but I ran into a few comments there and elsewhere that this was a bad idea. What would be the best way to accomplish allowing users to define the whole page? Also, why is the database a bad idea? Thanks.
Wade
The other way of passing the data from Controller to View can be by passing an object of the model class to the View. Erase the code of ViewData and pass the object of model class in return view. Import the binding object of model class at the top of Index View and access the properties by @Model.
Let's add one record from the browser by clicking the 'Create New' link. It will display the Create view. Let's add some data in the following field. Click on the Create button and it will update the Index view as well add this new record to the database.
From the Add New Item window, select ADO.NET Entity Data Model and set its Name as NorthwindModel and then click Add. Then the Entity Data Model Wizard will open up where you need to select EF Designer database option. Now the wizard will ask you to connect and configure the Connection String to the database.
We are going to discuss about displaying data in table format by using the following 3 ways, Using foreach loop. Uisng WebGrid. Using Jquery with Json Result Object.
Well if you can write the application using MVC 3 Beta instead of MVC 2 you can use this technique:
http://buildstarted.com/2010/11/02/razor-without-mvc-part-ii/
You can store your "View" as string in the database then just pull it out and pass it to the parse engine and you are all set.
It works great.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With