ASP. NET 3.5 Extensions: Dynamic Data Web Site to be sorted

Source: Internet
Author: User
Tags xml example

In the previous example, many cases were handled by the case transcript, IDE, and Dynamic Data framework. We just dragged them down with a mouse, go to web. set the atomicity in config. Even after the website is created, you may still feel a little unknown: why can the website be run? How does one batch of data come from? Therefore, we need to sort out the previous links in a short time here, hoping to make the Dynamic Data Web Site more complete.

The following sections detail the processes for creating a Dynamic Data Web Site and the customer segmentation of the website.

Several key points for creating a Dynamic Data Web Site

  • If you want to quickly create a website for adding, modifying, and querying resources, you can use VS2008 to directly create a Dynamic Data Web Site (you must first install ASP.. NET 3.5 Extensions preview ). Through this method, the website is mainly used with the scaffolding function of Dynamic Data.
  • Dynamic Data Web Site Scripting will automatically generate a page and format, including a first release (Default. aspx ). Of course, it does not know which data tables you want to handle. Therefore, you must fill in the blanks for this part. To be more clear, we need to establish a Data Context class. Data Context is a bit like a resource. There are many types of Data, each type of data corresponds to a data table in the actual database.
  • The method for establishing Data Context is to add a LINQ to SQL class to the example. If you name it Foo. dbml, in addition to producing Foo. dbml (this is an XML example) still produces Foo. dbml. layout and Foo. designer. cs: the former stores only the graphic dataset information of the design planner, and the latter contains the real Data Context class, while the latter class name may be FooDataContext. When you drag data tables from Server Explorer to The. Foo. dbml design region, IDE will help you establish the corresponding types in. designer. cs. In short, the IDE and Dynamic Data framework automatically handles the complex operations of object-relation mapping.
  • When you configure Default. aspx, the Dynamic Data framework will retrieve the Data table list and its metadata from the specified Data Context. So how can we tell the Dynamic Data framework which Data Context type should be used? The answer is in Web. config.<DynamicData>ElementDataContextTypeAdequacy.

Online Customization

  • The Graphic Structure of the indexing table is stored in the App_Shared \ DynamicDataPages project. There are three cases: ListTemplate. aspx, DetailsTemplate. aspx, and ListDetailstemplate. aspx. When you are at the beginning of the website (Default. aspx) Click here to link a Data table. The Dynamic Data framework will use these templates to present the metadata of the Data table.
  • If you want to create a custom data table, you can copy the preceding content to a specific data table under the root website, and remove the "Template" in the region name. The specified item indicates that the item name must be the same as the item table name. For example, you can create a database named MERs under the root category of the website to create a database named Customers from the MERs table, then, the platform will be downloaded to the item and then modified. From<DynamicData>Element<Mappings>Sub-ElementPatternsThe naming rules of the resource and the relationship between the name of the resource and the URI of the website.
  • You can use<DynamicField>It is designed to determine the positioning locations of the data table, as well as the presentation formats and positioning standards (HeaderTextWarning), alarm bit display/alarm control (RenderHintAdequacy ).

Self-Signed registrant Certificate

  • In ASP. NET 3.5 Extensions, three verification characters (validation attributes) can be used to apply to specific characters. They are:RequiredAttribute,RegexAttribute, AndRangeAttribute.
  • The following describes how to apply bitwise verification features: first create a partial class corresponding to an entity class in the App_Code Resource (for example, the first Customer. cs), and then apply the certificate feature to the class. Take the following example as an example:

    Using System. Web. DynamicData;

    [Required ("CustomerID", ErrorMessage = "cannot be blank! ")]
    Public partial class Customer
    {
    }

  • In addition to the internal certificate feature, the developer can also customize other certificate rules by "actual" in the self-built entity class 」On <FieldName> ChangingMethod. In this example, the "actual work" must use the partial methods syntax. Take the following example as an example:

    Public partial class Customer
    {
    Partial void OnCustomerIDChanging (string value)
    {
    If (String. IsNullOrEmpty (value ))
    {
    Throw new Exception ("guest cannot be blank! ");
    }
    }
    }

Control the memory of a self-contained hidden Digit

  • ASP. the NET Dynamic Data framework dynamically uses the Internal Control libraries to display and adjust the Dynamic bit values, for example: textBox is used for the character bit of the text type. The control lists of these metric data locations are called dynamic data fields, all of which are user controls. You can find the dynamic data volume control blocks created in the App_Shared \ DynamicDataFields resources on the website.
  • You can also design your own resource space control policies to control the internal resource space. In this case, right-click the App_Shared \ DynamicDataFields resource, Add New Item, and then select "Dynamic Data Field ". This method will help you generate two user controls. One is used to indicate the bitwise value and the other is used to indicate the bitwise value, and they are all single file encoding methods (rather than code-behind encoding methods ).
  • The dynamic resource level control role must be borne by the parent class:System. Web. DynamicData. FieldTemplateUserControlBase.
  • After setting the dynamic resource level control, you can use RenderHint to specify a certain bit to use your own control level to display and adjust it, there are two methods:
    (1) Specify the RenderHint encoding of the <DynamicField> label in the self-built network (such as MERs \ ListDetails. aspx. As follows:

    <Asp: DynamicField DataField = "OrderDate" HeaderText = "orders single date"RenderHint = "CalendarDate"/>

    (2) apply the RenderHint feature in the self-defined entity class, as shown below:

    [RenderHint ("OrderDate", "CalendarDate")]
    Public partial class Order
    {
    }

    The first parameter is the parameter name, and the second parameter is the parameter type of your dynamic resource space.

 

OK! This section describes the Dynamic Data Web site.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.