zoukankan      html  css  js  c++  java
  • AJAX 01 Loading function

    Following by: http://www.cnblogs.com/symjie520/archive/2007/04/17/716571.html

    Reference:  http://ajaxpro.codeplex.com/

     

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind
    ="Default.aspx.cs" Inherits="AJAX_Loading._Default" %>

    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
        
    <script language="javascript" type="text/javascript">
            
    function SignIn() {
                EnableControl(
    "login"true);

                
    var UserId = document.getElementById("userid").value;
                
    var Password = document.getElementById("password").value;

                AJAX_Loading._Default.GetLogin(UserId, Password, CallBackServer);

                document.getElementById(
    "loading").style.display = "block";
            }

            
    function CallBackServer(res) {
                
    var success = res.value;

                document.getElementById(
    "loading").style.display = "none";

                EnableControl(
    "login"false);

                
    if (success) {
                    document.getElementById(
    "ss").innerHTML = "Succeed";
                    
                }
                
    else {
                    document.getElementById(
    "ss").innerHTML = "Failed";
                }
            }

            
    function EnableControl(controlId,isDisabled) {
                
    var control = document.getElementById(controlId);
                control.disabled 
    = isDisabled;
            }
        
    </script>
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        
    <div>
            
    <table>
                
    <tr>
                    
    <td>
                        User Id
                    
    </td>
                    
    <td>
                        
    <input id="userid" type="text" />
                    
    </td>
                
    </tr>
                
    <tr>
                    
    <td>
                        Password
                    
    </td>
                    
    <td>
                        
    <input id="password" type="password"/>
                    
    </td>
                
    </tr>
                
    <tr>
                    
    <td>
                        
    <input id="login" type="button" value="Sign In" onclick="SignIn();" />
                    
    </td>
                
    </tr>
            
    </table>
        
    </div>
        
    <div id="loading" style="display: none;">
            Loading......
        
    </div>
        
    <div id="ss">
        
    </div>
    </asp:Content>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Threading;

    namespace AJAX_Loading
    {
        
    public partial class _Default : System.Web.UI.Page
        {
            
    protected void Page_Load(object sender, EventArgs e)
            {
                AjaxPro.Utility.RegisterTypeForAjax(
    typeof(_Default));
            }

            [AjaxPro.AjaxMethod]
            
    public bool GetLogin(string userId, string password)
            {
                Thread.Sleep(
    5000);

                
    return userId == "admin" && password == "admin";
            }
        }
    }
    <?xml version="1.0"?>

    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      
    -->

    <configuration>

      
    <configSections>
        
    <sectionGroup name="ajaxNet">

          
    <!--
                    If you are using Microsoft .NET 1.1 please remove the two attributes
                    requirePermission and restartOnExternalChanges, they are only supported
                    with .NET 2.0.
                
    -->
          
    <section name="ajaxSettings"
                    type
    ="AjaxPro.AjaxSettingsSectionHandler,AjaxPro.2"
                    requirePermission
    ="false"
                    restartOnExternalChanges
    ="true"
                
    />

        
    </sectionGroup>
      
    </configSections>
     
      
    <ajaxNet>
        
    <ajaxSettings>

          
    <urlNamespaceMappings useAssemblyQualifiedName="false" allowListOnly="false">
            
    <!--
                        Set the attribute useAssemblyQualifiedName to true to enable
                        use of assemblies placed in the GAC by using the full assembly
                        qualified name.
                    
                        To hide internal knowledge of assemblies, classes and namespace
                        you can override the name of the virtual http endpoints.
                        
                        <add type="Namespace.Class1,Assembly" path="mypath" />
                    
    -->
          
    </urlNamespaceMappings>

          
    <jsonConverters includeTypeProperty="true">
            
    <!--
                        This section can be used to add new IJavaScriptConverters to the
                        Ajax.NET Professional engine. If you want to disable built-in
                        converters you can use the remove tag.
                
                        <remove type="Namespace.Class1,Assembly"/>
                        <add type="Namespace.Class2,Assembly"/>
                        
                        <add type="AjaxPro.BitmapConverter,AjaxPro.2" mimeType="image/jpeg" quality="100"/>
                    
    -->
          
    </jsonConverters>

          
    <!--
                    Set the enabled attribute to true to get Stack, TargetSize and Source 
                    information if an exception has been thrown.
                
    -->
          
    <debug enabled="false" />

          
    <!--
                    This is the default configuration used with Ajax.NET Professional. You
                    can put there your static JavaScript files, or remove the path attribute
                    to completly disable the files.
                
                    <scriptReplacements>
                        <file name="prototype" path="~/ajaxpro/prototype.ashx" />
                        <file name="core" path="~/ajaxpro/core.ashx" />
                        <file name="converter" path="~/ajaxpro/converter.ashx" />
                    </scriptReplacements>
                
    -->

          
    <!-- <encryption cryptType="" keyType="" /> -->

          
    <!--
                    Set the enabled attribute to true to enable the use of an Ajax.NET Professional
                    token. This will send a token to the client that will be used to identify if the
                    requests comes from the same PC.
                
    -->
          
    <token enabled="false" sitePassword="password" />

          
    <!--
                    The oldStyle (or now configuration) section can be used to enable old styled JavaScript code or
                    functions that are not used any more. Some of them cannot be used together.
                
                    <configuration>
                        <renderNotASPAJAXDateTime/>
                        <objectExtendPrototype/>
                        <appCodeQualifiedFullName/>
                        <allowNumberBooleanAsString/>
                        <sessionStateDefaultNone/>
                        <includeMsPrototype/>
                        <renderDateTimeAsString/>
                        <noUtcTime/>
                        <renderJsonCompliant/>
                        <useSimpleObjectNaming/>
                    </configuration>
                
    -->

        
    </ajaxSettings>
      
    </ajaxNet>
      
      
    <connectionStrings>
        
    <add name="ApplicationServices"
             connectionString
    ="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
             providerName
    ="System.Data.SqlClient" />
      
    </connectionStrings>

      
    <system.web>
        
    <compilation debug="true" targetFramework="4.0" />

        
    <authentication mode="Forms">
          
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
        
    </authentication>

        
    <membership>
          
    <providers>
            
    <clear/>
            
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
                 enablePasswordRetrieval
    ="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
                 maxInvalidPasswordAttempts
    ="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
                 applicationName
    ="/" />
          
    </providers>
        
    </membership>

        
    <profile>
          
    <providers>
            
    <clear/>
            
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
          
    </providers>
        
    </profile>

        
    <roleManager enabled="false">
          
    <providers>
            
    <clear/>
            
    <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
            
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
          
    </providers>
        
    </roleManager>

      
    </system.web>

      
    <location path="ajaxpro">
        
    <system.web>
          
    <httpHandlers>
            
    <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
          
    </httpHandlers>
          
    <!--
                    If you need to have Ajax.NET Professional methods running on the
                    login page you may have to enable your own authorization configuration
                    here.
                
    -->
          
    <!--
                <authorization>
                    <deny users="?"/>
                </authorization>
                
    -->
        
    </system.web>
      
    </location>
      
      
    <system.webServer>
         
    <modules runAllManagedModulesForAllRequests="true"/>
      
    </system.webServer>
    </configuration>



     


  • 相关阅读:
    set与map
    统计一个字符串中出现了多少个不同的字符
    求序列中所有不同的连续子串的数量
    79、idea IDE Eval Reset
    78、idea控制台报 java: 无效的目标发行版: 14
    16、docker安装minio
    77、idea中添加maven项目右侧无maven
    76、mysql5.7安装教程
    74、js向上递归
    72、解决IntelliJIDEA没有Spring Initializr
  • 原文地址:https://www.cnblogs.com/sskset/p/1938811.html
Copyright © 2011-2022 走看看