转换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
分享到:
相关推荐
台湾董大伟之作,作者下了很大功夫的好作品,分析鞭辟入里,好著作 网速慢,分成四个文件
台湾董大伟之作,作者下了很大功夫的好作品,分析鞭辟入里,好著作 网速慢,分成四个文件
5. **实体框架(Entity Framework)**:ASP.NET通常与数据库交互,因此可能涉及到使用Entity Framework进行对象关系映射(ORM),这是一种强大的工具,可以将数据库操作转化为面向对象的代码。 6. **AJAX技术**:...
台湾董大伟之作,作者下了很大功夫的好作品,分析鞭辟入里,好著作 网速慢,分成四个文件
台湾董大伟之作,作者下了很大功夫的好作品,分析鞭辟入里,好著作 网速慢,分成四个文件