ASP. NET uses AjaxPro to implement front-end and background interaction details. asp. netajaxpro

Source: Internet
Author: User

ASP. NET uses AjaxPro to implement front-end and background interaction details. asp. netajaxpro

I used AjaxPro for interaction. Many people have written articles. Why do I have to keep talking about it. We need to pay attention to some details, because if you do not pay attention to these details, the program will report an error and the maintainability is poor.

Introduction

I. First of all, if you want to practice magic, you must first go to your own palace. The first step in program development is to build the environment.

When Visual Studio is started, my version is 2012, but this does not affect. Create a website project, add the Bin directory to the project, and then add an Index page.

Then, we need to download AjaxPro.2.dll from the Internet. Baidu has a bunch of links. I will not talk about it here. Copy or introduce the downloaded AjaxPro.2.dll file to the Bin directory. Then, write the following content under the <system. Web> tag of web. config.

In the server background class, make the following changes:

using AjaxPro;//(1)AjaxPro.Utility.RegisterTypeForAjax(typeof(Index));//(2)[AjaxPro.AjaxMethod]//(3)

(1): Introduce the AjaxPro namespace

(2): register information to the front-end page

(3): Add this before the function to be called on each front-end page

Here I have an instance. Note that a judgment is used in the Page_Load () function. If (Page. IsCallback), its function isObtain a value indicating whether the page request is a callback result. It has a special callback, so the round-trip always happens. However, unlike traditional sending-back, the script callback does not repaint the entire page.. This is crawled by other bloggers. This is the original article and a personal little programming habit. I don't know what the specific use is, but I know it is useful.

Above, we have finished setting up the AjaxPro.2 environment.

Ii. Next, we will start calling.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="Index" %><!DOCTYPE html>

Here, Index is the class name of this class. I don't know whether to remember it. We have written such a piece of code: AjaxPro. Utility. RegisterTypeForAjax (typeof (Index); Class Name stated during Environment configuration. The front-end page also finds our class through this .. Value is also a key point. I remember the first time I used this plug-in. If a Password is returned to determine whether the login is successful, it will always fail. This plug-in page uses the log information, so I can only hold alert one by one and finally let me hold it, if you do not use value here, you will get a lot of information that is not available for actual applications.

1) thought that the call was successful? So naive. Here we will talk about the first detail: Changing the managed pipeline model of the project

Click and select the project, and press F4 to display the properties of the project. Change this attribute to a traditional one. For integration, 500.23 is reported.

2) Another point is also an error. This error does not occur during compilation and does not occur during page loading. The error "Uncaught ReferenceError: Index is not defined" is reported only when AjaxPro.2 is called. When the background Code does not work, you must check whether this problem occurs because the error does not appear on the page, will not be compiled. To see this error, you must follow the F12 page for debugging. I know that Google Chrome's error is displayed on the Console tab, and other browser bloggers are not very clear about it.

The reason for this error is that the blogger has also checked a lot of information, but there are few specific descriptions. Here, the blogger can only make a summary of his own. If someone knows what is wrong, I hope you can actively correct me (be polite and make mutual progress !!). What is the analysis of the blogger? It is because something went wrong when the environment was set up. The building environment blogger has just explained clearly in the previous article. If this error occurs, there should be 7 reasons for this.

3) This is what a blogger told me! He said: During the call, the declared class name may not be used. You can use the [AjaxNamespace ("DEMO")] label to rename the class. The blogger tried it. It is indeed possible. Put this label in front of the called class. Remember to put it in front of the class. You can.

As you can see, the effect is achieved! This label is very practical.

Thank you very much for watching this article. I hope you can correct any errors described above by the bloggers. Please comment on this and let me know. I will verify and modify it in time, hoping not to mislead others. Thank you very much!

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.