Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Views from Database

Tags:

asp.net-mvc

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

like image 389
Wade73 Avatar asked Oct 31 '10 10:10

Wade73


People also ask

How pass data from database to view in MVC?

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.

Can we connect MVC to database?

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.

How fetch data from database and display in table in ASP.NET MVC?

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.

How show data from table in MVC?

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.


1 Answers

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.

like image 182
Jim Avatar answered Sep 22 '22 22:09

Jim