转换C#后代码 using System; using System.Data; using System.Configuration; 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 { private string returnValue; protected void Page_Load(object sender, EventArgs e) { string cbReference; cbReference = Page.ClientScript.GetCallbackEventReference(this, "''", "ReceiveServerData", ""); Button1.Attributes["onclick"] = cbReference; string ReceiverScript = ""; ReceiverScript += "<script>/n"; ReceiverScript += " function ReceiveServerData(DataFromServer)/n"; ReceiverScript += "{/n"; ReceiverScript += "document.all." + TextBox1.ClientID + ".value=DataFromServer;/n"; ReceiverScript += "}/n"; ReceiverScript += "</script>/n"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ReceiverScript",ReceiverScript); } public string GetCallbackResult() { return DateTime.Now.ToLongTimeString(); } public void RaiseCallbackEvent(string eventArgument) { returnValue=eventArgument; } protected void Button1_Click(object sender, EventArgs e) { } 原VB代码 Partial Class _Default Inherits System.Web.UI.Page Implements System.Web.UI.ICallbackEventHandler Protected Overridable Function GetCallbackResult() As String Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult Return Now End Function Dim returnValue As String Public Sub RaiseCallbackEvent(ByVal eventArgument As String) Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent returnValue = eventArgument End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim cbReference As String cbReference = Page.ClientScript.GetCallbackEventReference(Me, "''", "ReceiveServerData", "") Button1.Attributes("onclick") = cbReference Dim ReceiverScript As String = "" ReceiverScript += vbCrLf + "<script>" ReceiverScript += vbCrLf + "function ReceiveServerData(DataFromServer)" ReceiverScript += vbCrLf + "{" ReceiverScript += vbCrLf + "document.all." + TextBox1.ClientID + ".value=DataFromServer;" ReceiverScript += vbCrLf + "}" ReceiverScript += vbCrLf + "</script>" Page.ClientScript.RegisterClientScriptBlock(GetType(String), "ReceiverScript", ReceiverScript) End Sub End Class
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐