Aug 8, 2011

How to add Dynamic Data to an Existing Web Site - Scott Hunter - Site Home - MSDN Blogs

How to add Dynamic Data to an Existing Web Site - Scott Hunter - Site Home - MSDN Blogs: ""

I've had various people ask me if Dynamic Data can be added to an existing website and I've compiled a list of steps to do this. We hope to add a tooling gesture to Visual Studio in the future to automatically do these steps. Once these steps are complete you can start taking advantage of Dynamic Data functionality in your existing applications.

1) Create a dummy Dynamic Data Website project. Copy the DynamicData directory from it into your existing website. You should also copy the Site.css and Site.master files. The Default.aspx file is optional, it display a menu of tables in your data model, this file is only needed if you plan on having such a menu in your application.

2) You can copy the Global.asax file or if you already have such a file you can just add the model registration and url routes as below to the

<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Web.DynamicData" %>

void Application_Start(object sender, EventArgs e) {

MetaModel model = new MetaModel();

model.RegisterContext(typeof(YourDataContextType), new ContextConfiguration() { ScaffoldAllTables = false });

routes.Add(new DynamicDataRoute("{table}/{action}.aspx") {
Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
Model = model
});

}

3) In the section in web.config add the following assemblies:




4) In the / section add the following new tag prefix:

5) Enable the new ASP.NET Routing feature:

IIS 5/6/Casini

In the section add the following new module:

IIS 7

In the / section add the following:

In the / section add the following:

At this point you need to register your Linq to SQL data modelin step #2 and optionally enable scaffolding by setting ScaffoldAllTables := true in the registratoin line. At this point if you copied the Default.aspx from the dummy Dynamic Data application you can execute it to view the scaffold. You can also enable Dynamic Data in existing web pages that use GridView, ListView, FormView and DetailsView by adding a DynamicDataManager to those pages and then registering the data control with the dynamic data manger:

...

DynamicDataManager1.Register(GridView1);

Inside of your GridView or DetailsView you can either use AutoGenerateColumns or you can use DynamicField controls in your column collections. If you are using ListView or FormView use DynamicControl to display values for each of your columns.

No comments:

nice web tools English Definitions and Dictionary dutch definition and Dictionary , Nederlands definitie finnish definition and Dictionary, hollantilainen sanakirja French definition and Dictionary, le dictionnaire Français arabic definition and Dictionary, قاموس اللغة العربية hindi definition and Dictionary, शब्दकोश, हिन्दी शब्दकोश bengali definition and Dictionary, বাংলা অভিধান portuguese definition and Dictionary, dicionário de Português urdu definition and Dictionary، اردو لغت russian definition and Dictionary, русский словарь spanish definition and Dictionary, diccionario de español