An example of how to use Ajaxpro to complete front-end and background interaction with ASP.

Source: Internet
Author: User
This article is mainly for you to introduce in detail the use of ASP. Ajaxpro to achieve front-end and background interaction, with a certain reference value, interested in small partners can refer to

Use Ajaxpro to interact, many people have written articles, why should continue the cliché. Because there are some details we need to pay attention to, because these details if not pay attention to, then the program will error, and poor maintenance.

Introduction

First of all, or that sentence, to practice the martial, will be the first self-palace. The first step in our development process is to build the environment.

Start Visual Studio, my version is 2012 Ah, but this does not affect. First create a Web site project, add the Bin directory to the project, and an Index page.

Then, we need to go online download ajaxpro.2.dll Baidu A bunch of links, here I will not say anything more. The downloaded ajaxpro.2.dll files are then copied or introduced into the Bin directory. Next, write the following in the <system.web> tab of the Web. config .



And in the server background class, make the following modifications:


Using ajaxpro;//(1) AjaxPro.Utility.RegisterTypeForAjax (typeof (Index));//(2) [ajaxpro.ajaxmethod]//(3)

(1): Introducing the Ajaxpro namespace

(2): Registration information to the front page

(3): Each foreground page needs to call the function before adding this

Here I have an example, one thing to note: in the Page_Load () function, a judgment is used. if (page.iscallback) It does this by getting a value that indicates whether the page request is the result of a callback. It's a special callback, so the round trip always happens; however, unlike traditional postbacks, script callbacks do not redraw the entire page . This is in other bloggers crawling, this is the original, but also a small personal programming habits, I do not know what the use, but I just know that useful.

Above, we have built this ajaxpro.2 environment.

Two. Next, the call is started.


<%@ page language= "C #" autoeventwireup= "true" codefile= "Index.aspx.cs" inherits= "Index"%><! DOCTYPE html>

Here, Index is the class name of this class, do not know whether remember. We have written this piece of Code AjaxPro.Utility.RegisterTypeForAjax (typeof (Index)); The class name that is declared when the environment is configured. The front-end page also finds our class through this: value is also a focus, I remember the first time I used this plugin. Return a Password to determine whether the login success, has always been a failure, this plugin page with log information, I can only one alert finally let me grasp, if there is no value to get a lot of actual applications do not use the information, here need to pay attention.

1) Think this will make the call successful? It's naïve, here we say the first detail: Change the managed pipeline mode for a project

Click the mouse button to select this item, and then press F4 to show the properties of this item. Change this property to the traditional type, it's OK. If it is integrated, it will be reported 500.23

2) There is also a point, also a mistake. This error compiles without errors and does not occur when the page is loaded. Only call to Ajaxpro.2 is the time to error uncaught Referenceerror:index is not defined when calling the background code does not work, you need to pay attention to whether this problem, because this error it will not appear on the page, and will not be compiled. To see this error, you must press the F12 page to debug, I know that Google Chrome error appears in the Console tab, other browser bloggers are not particularly clear.

The reason for this error, bloggers have also looked up a lot of information, but very few specific description. Here bloggers can only do a blogger's own summary, if someone knows where there is a mistake, I hope you can positively correct (don't be polite, mutual progress ah!!) )。 Blogger analysis, is because of the environment, where there is a problem. Build environment bloggers have just said in the previous article is relatively clear, if this error occurs, there should be 70% is the reason.

3) This is also a blogger told me the details Ah! He said so: when calling, you don't have to use the name of the class you're declaring. This class can be renamed using the [Ajaxnamespace ("DEMO")] tab. The blogger tried it, and it was really possible. Put this tag in front of the class being called, remember it is the class front oh. You can do it.

As you can see, the effect is realized! This label is still very useful.

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.