zoukankan      html  css  js  c++  java
  • c# 通过ICallbackEventHandler 实现页面“无刷新”

    C#   前台代码

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

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script type="text/jscript">
    function getvalue()
    {
        var value1 =document.getElementById("Text1").value;
        var aa ="";
        <%=gg() %>  
    }
    function setvalue(result)
    {
    document.getElementById("Text2").value=result;
    }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <input id="Text1" type="text" />
            <input id="Button1" type="button" value="button" onclick="getvalue();"/>
            <input id="Text2" type="text" />
        </div>
        </form>
    </body>
    </html>

    c#后台代码

    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 Default25 : System.Web.UI.Page,ICallbackEventHandler
    {
        string testvalue = "";
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public string gg()
        {
            return ClientScript.GetCallbackEventReference(this, "value1", "setvalue", "aa");
        }

        #region ICallbackEventHandler 成员

        public string GetCallbackResult()
        {
            return testvalue;
        }

        public void RaiseCallbackEvent(string eventArgument)
        {
            testvalue = eventArgument + "1";
        }

        #endregion

  • 相关阅读:
    将16进制的颜色值变成UIColor
    验证邮箱地址方法
    iOS 推送通知详解
    在UITextView中添加placeholder
    移除所有子视图removeAllSubviews
    如何书写高质量的jQuery代码
    reset.css
    CSS3笔记
    10个可以直接拿来用的JQuery代码片段
    js定时器
  • 原文地址:https://www.cnblogs.com/gengaixue/p/1325979.html
Copyright © 2011-2022 走看看