zoukankan      html  css  js  c++  java
  • asp.net 2.0 中ICallbackEventHandler的使用(无刷新页面)




    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        
    <title>Untitled Page</title>
        
    <script>
         
    function callToServer()
    {
        
    var param = document.getElementById("txtMessage").value;
        
    var context = "";
    <% = blientScript %>  
    }


    function handleResultFromServer(result, context)
    {
        document.getElementById(
    "txtResult").value = result;
    }

        
    </script>
    </head>
    <body>
        
    <form id="form1" runat="server">
        
    <div>
        
    <INPUT id="txtMessage" />
    <INPUT onclick="callToServer();" type="button" value="Call to Server" id="Button1" />
    Result : 
    <INPUT id="txtResult" />
        
    </div>
        
    </form>
    </body>
    </html>


    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class _Default : System .Web.UI .Page , System.Web.UI.ICallbackEventHandler
    {
        
    protected void Page_Load(object sender, EventArgs e)
        
    {
           

        }

       
    protected  String blientScript
        
    {
            
    get
            

                
    return this.ClientScript.GetCallbackEventReference(this"param""handleResultFromServer""context");
            }

        }


        
    public string RaiseCallbackEvent(string eventArgument)
        
    {
            
    return "客户端在[" + DateTime.Now.ToString() + "]传送来 [" + eventArgument + "].";
        }



    }


    原来作者那个无法通过调试....应当这样...
     
    return this.ClientScript.GetCallbackEventReference(this"param""handleResultFromServer""context"); //应当这样 在 (asp.net beta2 中)


    //参考

    http://blog.joycode.com/kaneboy/archive/2004/07/07/26914.aspx

  • 相关阅读:
    Oracle EXP-00091解决方法
    Oracle 表空间的概念
    每天一点点oracle
    ntp服务问题
    Centos 7.4 安装samba服务
    Oracle group by
    Ansible介绍
    Gitlab应用——开发人员fetch分支,合并到master主分支申请
    Gitlab应用——系统管理
    Gitlab安装配置管理
  • 原文地址:https://www.cnblogs.com/gwazy/p/207477.html
Copyright © 2011-2022 走看看