ASP. NET Ajax series (1)

Source: Internet
Author: User

We often use Ajax technology in Web development. There are also many ways to implement Ajax technology. Let's start with the first method: ASP. NET native control to implement Ajax today. ASP. NET native controls are mainly used in Ajax technology UpdatePanel and ScriptManager. The former, as the name suggests, is a container that can be used to hold content and implement partial page updates, you can directly add the content to be updated when using it. The latter is used to call some services and scripts: for example, we use JavaScript to call the WebService in this Demo. This Demo mainly contains a page, a Web service and a common data operation class (userHelper) to implement the function of checking whether the nickname exists during registration without refreshing the page. First, we need to create a Web Page (WebForm is used here). The general code is as follows: <% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "WebForm2.aspx. cs "Inherits =" WebApplication1.WebForm2 "%> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head runat =" server "> <title> register </title> <script type =" text/javascript "> function check () {var Name = document. getElementById ("txtName "). value; if (Name = "") {alert ("nickname cannot be blank! ");} Else {WebApplication1.WebService1. checkName (Name, callbackCheck); function callbackCheck (result) {if (result = false) {document. getElementById ("checkFont "). innerHTML = "<span> this nickname already exists! Enter again! </Span> ";}else {document. getElementById (" checkFont "). innerHTML =" <span> congratulations! This nickname can be used! </Span> ";}}}</script>

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.