Databinding with Dynamic Languages for ASP.NET

06/21/2009
Prerequisites

In order to complete this walkthrough, you will need the following:

  • Microsoft Visual Studio 2008 or Visual Web Developer 2008 Express Edition.
  • A copy of the website included in the ASP.NET Dynamic Language Support download. There is currently no project template, so it is necessary to copy the website in order to start with a blank ASP.NET Dynamic Language website.
  • The Northwind.mdb file that contains the Access version of the sample Northwind database. This file is included in the ASP.NET Quickstarts. If you installed the ASP.NET Quickstarts with Visual Studio, the file is located in the QuickStart\aspnet\samples\data\App_Data folder. Alternatively, you can use another database and adjust the steps in the walkthrough to match the database and tables that you are using.

 

Creating the Web Site and Page

If you have already created a Web site in Visual Studio (for example, by working with the companion walkthrough Using Dynamic Languages with ASP.NET), you can use that Web site and go to the next part of the walkthrough, where you add an Access database to the project. Otherwise, create a new Web site and page by following these steps.

To create a Web site with a default ASP.NET Web page

  1. Copy the files from the ASP.NET Dynamic Language Support project into an empty directory.
  2. In Visual Studio (or Visual Web Developer), in the File menu, click Open Web Site. The Open Web Site dialog box is displayed.
  3. Select the directory in which you copied the files in step 1. Make sure that FileSystem is selected in the left panel of the dialog.

    Note: You can use statically compiled languages in the same Web application by creating pages and components in different programming languages.

  4. Click Open. Visual Studio opens the folder as a website and displays the files in the Solution Explorer.

Next you will add the Northwind.mdb Access database or your own database to the Web application project.

To add an Access database to the project

  1. If the Web site does not already contain an App_Data folder, in Solution Explorer, right-click the name of your Web site, click Add ASP.NET Folder, and then click App_Data.
  2. In Visual Studio, in Solution Explorer, right-click the App_Data folder, and then click Add Existing Item.
  3. In the Add Existing Item dialog box, browse to the Northwind.mdb file, and then click Add.
Posted in: Website-asp.net| Tags: .NET asp.net Dynamic Data Prerequisites Website database asp dynamic visual file walkthrough order

Dynamic Data Samples for Preview 4

06/21/2009

This is the primary project sample that shows most of the new functionality that has been added to Dynamic Data since .NET 3.5 SP1. The default.aspx page highlights many of the new items that are being added in .NET 4, in particular:
• Filter Templates. Filters are now first class citizens in Dynamic Data. There is a new FilterTemplate directory that contains the default filter templates and supports user defined filter templates. Filters can be applied to columns using the new FilterUIHint attribute.
• Entity Templates – The Details, Edit and Insert page templates in version 1.0 forced a two column display style (field name, field value). Entity templates allow for the layout  of an entity to be  arbitrarily customized.
• Field Templates. The following new field templates have been created.
• Email Field Template. Data fields in the model that are marked with DataType(DataType.Email) will be displayed as mailto: hyperlinks that will launch the email client when clicked.
• Url Field Template. Fields in the model that are marked with DataType(DataType.Url) will be displayed as hyperlinks that will open a new window with the given URL.
• Many to Many Relationships in Tables. Entity Framework models support many to many relationships. Dynamic Data will display these as a list of values or in edit mode a list of checkboxes for the selectable columns.
• Enumeration on Model. If a column in the model is associated with an enumeration data type it will be displayed as a dropdown list of the values from the enumeration.
• Enumeration using Metadata. If a column in the model has an EnumDataType(typeof(enum)) attribute it associated with an enumeration data type it will be displayed as a dropdown list of the values from the enumeration.
• Inheritance. Both Entity Framework and Linq to SQL support inheritance relationships in their data models. Dynamic Data will now properly display this data.

This sample also shows some other advanced features in Dynamic Data such as
• Multiple Data Models
• Each data model uses a different data model technology.
• Each registers its own custom DynamicData directory.

This sample project demonstrates new functionality that allows Dynamic Data field templates to be used by applications without any requirements (no data model is required (but can be used), no routing is required, no registration globally is required. Just take a data control and use the code DataControl.EnableDynamicData. This automatically gives the data control automatic validation and supports the attributes in System.ComponentModel.DataAnnotations.

• DataTable Sample. This sample shows how to use Dynamic Data with ADO.NET DataTable/DataSets including how to add metadata from System.ComponentModel.DataAnnotations to a DataTable.
• Set Insert Defaults Sample. This sample demonstrates a common customer’s request of something that is difficult to do in ASP.NET and Dynamic Data and that is to provide default values at runtime for fields in a data control that is in insert model (typically the developer uses FindControl to try and find the control and set its value). With this new functionality you can create an anonymous object and set the names of parameters to the value of choice ( new { Name = “DefaultName”; } ).
• ObjectDataSource Sample. This sample demonstrates Dynamic Data controls being used with the traditional ObjectDataSource. Just call EnableDynamicData with the type of the object being bound to ObjectDataSource and it all works.

Posted in: .NET Framework| Tags: .NET Dynamic Data Sample CTP Page dynamic entity templates default

ASP.NET Dynamic Language Support

06/11/2009
Introduction
Dynamic Languages are a class of high-level programming languages that do not rely on static typing. Many decisions that are made at compile time by a statically typed language are instead made at run time by a dynamic language. For example, many dynamic languages use dynamic typing, where an object’s type is determined at run time instead of at compile time. These languages make a trade-off between compile-time type-checking in favor of increased flexibility at run time.
There are many good static languages, such as C#, and many good dynamic languages, such as IronPython. The choice of what type of language to use comes down to personal preference and to the nature of the project you’re working on.
Giving ASP.NET users the choice of languages was part of the design since our first version of ASP.NET, and this Dynamic Language Support is just another step in that direction. Unlike other Web platforms that support only one language, the ASP.NET team wants to enable users to choose the language that fits them best.
This Release
This release is compatible with IronPython 2.6 Beta 1. Currently it does not include Language Services Support and project templates. To create a new IronPython ASP.NET WebForms project, simply copy the “examples\hello-webforms” to a new directory and rename the directory to your liking. A redistributed copy of IronPython 2.6 Beta 1 can be found in the “bin” directory; all files except Microsoft.Web.Scripting.dll, the IronPython ASP.NET integration, are from the IronPython 2.6 Beta 1 release.
Included in this release are two WebForms examples that are written in IronPython: “hello-webforms” and “album-handler”, which can be found in the “examples” directory. “hello-webforms” is a simple web application that shows PostBack handling, and “album-handler” is a larger web application that creates a photo album from a directory of images and generates thumbnails for them on the fly.
Current Limitations
There are some tooling limitations with this release:
  • Limited support for designers
  • No IntelliSense support.
  • No support for ASP.NET MVC. This is planned in the future by extending the IronRuby ASP.NET MVC support: http://github.com/jschementi/ironrubymvc.
Why?
If you are an ASP.NET developer interested in trying out the simplicity and flexibility of a dynamic language, then this is for you - or if you are already investigating IronPython, then this opens up the door to developing ASP.Net Web applications using that language. For those interested in building ASP.NET applications with IronRuby, that's coming. Posted in: Website-asp.net| Tags: asp.net Dynamic Language Support Introduction Support languages run language class asp dynamic

Hot Posts

Latest posts

Tags

Others

Sponsors