Recommended for English reading: Use Ajax + WF + LINQ to create a Google ig Homepage

Source: Internet
Author: User

If you want to learn ASP. net Ajax, want to learn windows Workflow Foundation, and also want to learn LINQ (including dlinq and xlinq ), the kinder is the most recommended Article in random clipping.

Build Google ig like Ajax start page in 7 days using ASP. NET Ajax and. Net 3.0

After clicking the link to open the article, I believe most of the first response from readers is "wow! So long, how can this be done !" Since the title of the article uses seven days to create such a homepage, you can also add the article to the favorites with Del. icio. us and read it separately for several days. It may take some time to learn new things. When you read the seven-day development record of Omar Al zabir with patience, you can further understand its design with the source code, I believe you will be able to understand the several new technologies it uses, at least know what development scenarios it is used to save time and improve efficiency. If you think this article is too long, you can add it to your favorites and wait until you have time to read it again.

Introduction

First, let's take a look at the introduction section before the work record. Introduction in Section 1 shows that the implementation result of this project is relatively close to the real Google ig. It allows drag-and-drop widgets, fully personalized pages, and multi-page support. It also shows that it is not a prototype project or sample project, but a truly open-source homepage: http://www.dropthings.com /. You can use it in your daily life, or use ASP. NET to develop more widgets for it.

If you do not quite understand what the so-called "Homepage" is, what is an Web 2.0 Ajax start page in Section 2 provides a detailed explanation. The features in Section 3 briefly describes its functions. In fact, these functions are almost the same as Google ig, without adding anything new. In my opinion, compared with Google ig, the feature that really should be emphasized is that you can design widgets for it like developing common usercontrol without understanding XML and JavaScript, this is exactly what widgets described in section 4. Section 5 technologies describes the technologies used in this project. Can't you see the word ASP. NET Ajax future CTP? That means you don't need to reach out and touch Javascript. All you need to do for Ajax implementation is to write the server-side code to call updatepanel and extender.

Layered

Next, let's take a look at the special layers of this project from the perspective of layering, including web layer and data access using dlinq. In the web layer section, the author emphasizes that "the whole application is a page", and common tasks such as loading current user settings are completed by calling workflow, the actual test data shows that the running time of workflow is very short.

In the data access using dlinqsection, the operator uses sqlmetal.exe provided by dlingto directly generate data category classes. These classes contain all the data access code and entity classes. Then, the author compares the data with the third-party ORM tools by using the dling root tool, indicating that the project tion technology unique to dling can generate corresponding attributes based on the fields you need, this depends on the features of the custom compiler, so it cannot be implemented by a third-party ORM tool for the time being. The benefit it brings to you is the efficiency improvement, because you actually do not have the Select fields that you will not use. The author also said that if you do not believe in dlinq performance or have a bad feeling about dlinq, you can directly use SQL profiler to check what the SQL statements dlinq allows the database to actually execute.

Day 1: Use updatepanel to create a widget container

The so-called everything is difficult at the beginning, and the widget container to be designed on the first day is not easy. Don't look at the final generation of simple nested Div layers, so that it can be expanded, collapsed, and dragged and dropped, in addition, it is not so easy to execute to meet the efficiency requirements.

In this section, you need to pay attention to the extender placement problem, which makes how to nest the design a challenge. If the extender is placed in updatepanel, every updatepanel update will cause the entire extender client code to be destroyed and re-generated. It will also need to be re-initialized once, leading to inefficiency. Therefore, make sure that the extender is outside the updatepanel, and the final nested design can be viewed in the author's diagram.

As for widgetcontainer, It inherits from iwidgethost. This design reserves sufficient space for future extensions. The currently designed widgets can depend on some unique features of widgetcontainer, or they can only rely on iwidgethost to adapt to other iwidgethost containers in the future.

Day 2: create custom drag-and-drop extender and multi-column Placement Areas

In this section, the author explains why the original drag-and-drop extender is not applicable to this project, so you need to design a new extender. In fact, I also think ASP. net Ajax and Control Toolkit comes with a variety of Drag and Drop functions are indeed a lot of restrictions, and cannot be customized according to your development needs, so use ASP. net Ajax is almost certainly required if you need to use drag and drop, you have to write it yourself. Of course, this does not need to be written from the beginning. Future CTP has a built-in drag-and-drop manager for the client. You only need to implement two interfaces to implement drag-and-drop.

In addition, most extender stores the status on the server through asynchronous PostBack, which is not possible for the home page, because the user may need to drag and drop the next time immediately after one drag and drop, therefore, this custom drag-and-drop extender saves the status by calling Web service.

Day 3: create a data access layer and site Loading

In this section, the author shows the database design of this project and explains how to access data through dlinq across layers. The problem with cross-layer dlinq is that if your object is used for different layers, it will be separated from the datacontext (detach) that loads it, generally, the business logic layer does not have datacontext, so you need to send it back to the data access layer and then update it using datacontext, generally, we use the business logic layer to modify the entity and then send it back to the data access layer. dlinq requires that the entity be attached (attach) to datacontext before modification and then submit the update.

The author uses delegate to solve this problem. When calling the data access layer update function, a delegate is passed in. Then, the data access layer attaches the entity to datacontext, calls the delegate, and finally submits the update. The delegate points to the function in the business logic layer, which maintains the original hierarchy and completes the update according to the method required by dlinq, although this leads to an additional round-trip between two layers. In addition, the same design method can be used for insertion and deletion.

Day 4: Create a photo and RSS widget with xlinq

The first widget that the author wants to make is used to display the Flickr photo. First, load RSS through xelement, and then use xlinq to film XML into an object set. Then, it is easy to iterate through a specific range of objects in the set through xlinq and build the corresponding control tree, common RSS widgets are also made in a similar way. Imagine how you can complete this function without xlinq, and then look at the Code provided by the author, you will know how much time xlinq saves for you.

It is worth noting that the author uses htmlgenericcontrol to generate links, rather than htmllink, because htmllink does not allow sub-controls, which is a special limitation, htmlgenericcontrol can solve this problem well.

Day 5: Create a workflow in the business logic layer

This is a day with many problems. It is not easy to mix dlinq and winfx. The author needs to solve the following problems:

  • Synchronously calling workflow in ASP. NET
  • Get the object after running Workflow
  • Call another Workflow synchronously in one Workflow

The first problem is solved by adding two services to workflowruntime. The second problem is solved by creating a new activity called callworkflowactivity. The implementation of this activity is very complicated. If you are interested in the details, you can read this article: A workflow sample. Because workflow is designed to be executed asynchronously, the server processing of ASP. NET requires synchronization, so these two problems will occur. The third problem is that workflow is designed to be sleep. In this case, the data must be serialized and then persisted. However, the dlinq entity is not serializable. The solution to this problem is to put the dlinq object in the dictionary <string, Object>, so that the object can be serialized through the check.

In addition, to load the winfx and dlinq compilers in the same project at the same time, you need to modify the project file. The author provides the modification method. However, the declared rules of workflow cannot be compiled normally after modification, because the. Rules file cannot be recognized as an embedded resource normally, which seems to be a dead end. Until the next morning, there was silence around us, and the sun was about to rise. The author heard the holy revelation from heaven and understood how to solve the problem, if you want to learn more, read the original article carefully.

Day 6: Page Switching

During page switching, the new page widgets are loaded for the first time. If they determine whether they are loaded for the first time through the ispostback attribute, they will get an error message, then, an attempt to restore the last state based on viewstate will fail and thus the initialization will fail. The solution is to automatically notify the widget through widgetcontainer. This is not your first load.

I want to add some additional questions here. I don't think this is an effective solution. If you design a widget and throw a performancecontrol and a databoundcontrol on it, loading may fail, because these controls are designed to depend on the ispostback attribute, they automatically decide whether to bind data based on the ispostback attribute. We hope ASP. NET 3.0 can solve this problem, because we do need to bind data when loading databoundcontrol dynamically. In this case, the ispostback attribute is true.

Seventh Day: Registration

It is time to welcome the first registered user. At this time, you need to copy the settings used for anonymous access to the registered user. Because the information of anonymous users is not stored in aspnet_membership, but only in aspnet_user and aspnet_profile, membership cannot be used. getuser obtains the entity of an anonymous user and obtains its settings. In this case, you need to manually access the database to complete the above copy operation.

Before using dlinq to query aspnetdb, you should first read another article in Omar Al zabir: careful when querying on aspnet_users, aspnet_membership and aspnet_profile tables used by ASP. NET 2.0 membership and profile provider. All indexes in aspnetdb use the combination of applicationid and lowerusername or loweremail. To ensure efficiency, you must also use the preceding combination as the query condition.

Ending

Because this project is mixed with ASP. NET Ajax, winfx, and LINQ, there must be a hybrid web. config so that they can coexist harmoniously. This is exactly what the web. config walkthrough section will talk about. The following sections deployment problem and how to run the Code describe how to deploy the project and run it. The next steps section explains how to use ASP. net is developing more widgets for this project, while the conclusion section shows how challenging it is to mix these three technologies into a project, however, they also greatly reduce your development difficulty.

Summary

In the middle, I skipped how slow is ASP. net Ajax does not mention this section. Here the author explains that when the number of updatepanel and extender of a page increases to a certain extent, the client's execution speed will become very low. Later, according to Scott Guthrie's reminder. set DEBUG = "false" in config. This will disable the verification function during script running on the client. The execution speed is good, and the speed of IE7, ff, and opera9 is significantly improved, however, IE6 is still slow.

This shows that for Ajax applications with only one page, using updatepanel and extender is not a good solution unless you have sufficient capabilities to improve execution efficiency through various hacking methods. However, I think that if you have the ability to develop a client-centered Ajax application with future CTP, You can minimize the dependency on server-side controls and extender.

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.