当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > Asp.Net中的脚本回调和Server.Transfer页面传值

ASP.NET
使用 ASP+ 列表绑定控件(中)
使用 ASP+ 列表绑定控件(下)
关于两代语言.C/C++,java/c#
C#语言初级入门(1)
C#语言初级入门(2)
C#语言初级入门(3)
C#语言初级入门(4)
Microsoft .NET 框架常见问题 (一)
Microsoft .NET 框架常见问题 (二)
ASP.NET实现HTTP方式获取功能
Microsoft .NET Romoting 框架简介
ASP.NET中的XML表单控件
在 ASP.NET 中使用多个 runat=server form
.NET之ASP Web Form快速入门(1)
.NET之ASP Web Form快速入门(2)
.NET之ASP Web Form快速入门(3)
.NET之ASP Web Form快速入门(4)
.NET之ASP Web Form快速入门(6)
C#的前途如何?
在ASP.NET中处理 datetime 的一些通用函数(vb)

ASP.NET 中的 Asp.Net中的脚本回调和Server.Transfer页面传值


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 94 ::
收藏到网摘: n/a

在Asp.Net中经常要用到脚本回调和页面间的传值,下面是关于ScriptCallBack和Server.Transfer简单的示例代码WebForm1.aspx给Head中增加__doPostBack脚本,如果页面含有HyperLink等按钮控件,该脚本和2个隐藏控件"__EVENTTARGET"和"__EVENTARGUMENT"由FrameWork自动生成,若没有需要手动添加
ScriptCallBacksometext C#WebForm1.aspx.csprivate void Page_Load(object sender, System.EventArgs e){ if (IsPostBack) if (Request.Form["__EVENTARGUMENT"]== "ScriptCallBack") Server.Transfer("WebForm2.aspx", true);//第二个参数指示是否保留页面的Form和QuerryString的值}WebForm2.aspx.csprivate void Page_Load(object sender, System.EventArgs e){ if(this.Context.Handler != sender) Response.Write(Request.Form["TextBox1"]);}VB.NETWebForm1.aspx.vbPrivate Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IsPostBack Then If Request.Form("__EVENTARGUMENT") = "ScriptCallBack" Then Server.Transfer("WebForm2.aspx", True)'第二个参数指示是否保留页面的Form和QuerryString的值 End If End IfEnd SubWebForm2.aspx.vbPrivate Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Me.Context.Handler Is sender Then Response.Write(Request.Form("TextBox1")) End IfEnd Sub