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>



     


  • 相关阅读:
    10条建议帮助你创建更好的jQuery插件
    jQuery的end()方法使用详解
    jquery合并表格中相同文本的相邻单元格
    jQuery动态星级评分效果实现方法
    jQuery过滤HTML标签并高亮显示关键字的方法
    jQuery实现高亮显示网页关键词的方法
    深入.net调用webservice的总结分析
    C#中遍历各类数据集合的方法总结
    asp.net后台cs中的JSON格式变量在前台Js中调用方法(前后台示例代码)
    使用交叉验证对鸢尾花分类模型进行调参(超参数)
  • 原文地址:https://www.cnblogs.com/sskset/p/1938811.html
Copyright © 2011-2022 走看看