国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 儋州市| 漾濞| 孝昌县| 都匀市| 任丘市| 广昌县| 永善县| 青神县| 吴川市| 循化| 仲巴县| 邵阳县| 息烽县| 苍南县| 沁源县| 辉南县| 合川市| 远安县| 临泉县| 拜城县| 巴南区| 宣化县| 沛县| 隆林| 宜良县| 金秀| 灵武市| 阳曲县| 福鼎市| 永昌县| 湟源县| 临沧市| 荥阳市| 辛集市| 河东区| 萍乡市| 青川县| 孝义市| 新泰市| 忻州市| 宜兴市|