国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

如何在無刷新頁面的情況下實現(xiàn)客戶端回調(diào)實例(C#)—MSDN學(xué)習(xí)筆記

2019-11-18 17:06:00
字體:
供稿:網(wǎng)友

經(jīng)常在網(wǎng)上找各種各樣的資料看,來解決某一具有針對性的問題,可是最終發(fā)現(xiàn)還是MSDN好,可惜大部分沒有漢化,而且實例型的資料并不是很多,但不管怎么說MSDN還是需要我們認真學(xué)習(xí)的!
<%@ Page Language="C#" AutoEventWireup="true"
  CodeFile="ClientCallback.aspx.cs" Inherits="ClientCallback" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
  1.1//EN" "

<html xmlns="<head runat="server">
  <scr
ipt type="text/javascript">
    function LookUpStock()
    {
        var lb = document.forms[0].ListBox1;
        var PRoduct = lb.options[lb.selectedIndex].text
        CallServer(product, "");
    }
   
    function ReceiveServerData(rValue)
    {
        Results.innerText = rValue;
    }
  </script>
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <asp:ListBox ID="ListBox1" Runat="server"></asp:ListBox>
      <br />
      <br />
      <button onclick="LookUpStock()">Look Up Stock</button>
      <br />
      <br />
      Items in stock: <span ID="Results"></span>
      <br />
    </div>
  </form>
</body>
</html>

 1 using System;
 2 using System.Data;
 3 using System.Configuration;
 4 using System.Collections;
 5 using System.Web;
 6 using System.Web.Security;
 7 using System.Web.UI;
 8 using System.Web.UI.WebControls;
 9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12 public partial class ClientCallback : System.Web.UI.Page,
13      System.Web.UI.ICallbackEventHandler
14 {
15     protected System.Collections.Specialized.ListDictionary catalog;
16     protected void Page_Load(object sender, EventArgs e)
17     {
18         String cbReference =
19             Page.ClientScript.GetCallbackEventReference(this,
20             "arg", "ReceiveServerData", "context");
21         String callbackScript;
22         callbackScript = "function CallServer(arg, context)" +
23             "{ " + cbReference + "} ;";
24         Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
25             "CallServer", callbackScript, true);
26
27         catalog = new System.Collections.Specialized.ListDictionary();
28         catalog.Add("monitor", 12);
29         catalog.Add("laptop", 10);
30         catalog.Add("keyboard", 23);
31         catalog.Add("mouse", 17);
32
33         ListBox1.DataSource = catalog;
34         ListBox1.DataTextField = "key";
35         ListBox1.DataBind();
36     }
37
38     public String RaiseCallbackEvent(String eventArgument)
39     {
40         String returnValue;
41         if (catalog[eventArgument] == null)
42         {
43             returnValue = "-1";
44         }
45         else
46         {
47             returnValue = catalog[eventArgument].ToString();
48         }
49         return returnValue;
50     }
51 }


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 长海县| 福安市| 灵武市| 楚雄市| 满城县| 伊金霍洛旗| 桂林市| 教育| 丘北县| 嘉黎县| 阳东县| 黄平县| 临海市| 浦江县| 晋城| 尉犁县| 皋兰县| 乡城县| 荆州市| 海淀区| 会理县| 镇江市| 应用必备| 始兴县| 清苑县| 嘉荫县| 道孚县| 平罗县| 深泽县| 东阳市| 新蔡县| 保康县| 威海市| 贺州市| 兴义市| 邵武市| 抚松县| 三原县| 桑植县| 大洼县| 曲松县|