【经常在网上找各种各样的资料看,来解决某一...... 经常在网上找各种各样的资料看,来解决某一具有针对性的问题,可是最终发现还是MSDN好,可惜大部分没有汉化,而且实例型的资料并不是很多,但不管怎么说MSDN还是需要我们认真学习的! <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ClientCallback.aspx.cs" Inherits="ClientCallback" %> 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 } |
|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )
GMT+8, 2024-9-30 03:35 , Processed in 0.124491 second(s), 12 queries , Gzip On, MemCache On.
Powered by Discuz! X3.5
© 2001-2023 Discuz! Team.