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

ASP.NET
ASP.NET入门教程:ArrayList对象
ASP.NET入门教程:Hashtable对象
ASP.NET入门教程:SortedList对象
ASP.NET入门教程:把XML文件绑定到列表控件
ASP.NET入门教程:Repeater控件
ASP.NET入门教程:DataList控件
ASP.NET入门教程:数据库连接
ASP.NET入门教程:ASP.NET 2.0新特性
ASP.NET入门教程:ASP.NET 2.0母版页
ASP.NET入门教程:ASP.NET 2.0导航
ASP.NET入门教程:HTML服务器控件
ASP.NET入门教程:Web服务器控件
ASP.NET入门教程:Validation服务器控件
HTML服务器控件介绍:HtmlAnchor控件
HTML服务器控件介绍:HtmlButton控件
HTML服务器控件介绍:HtmlForm控件
HTML服务器控件介绍:HtmlGeneric控件
HTML服务器控件介绍:HtmlImage控件
HTML服务器控件介绍:HtmlInputButton控件
HTML服务器控件介绍:HtmlInputCheckBox控件

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 117 ::
收藏到网摘: 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