Server.Transfer页面跳转传递控件值得解决方案
来源:互联网 发布:轿子知乎 编辑:程序博客网 时间:2024/05/17 23:27
今天在CSDN上看到这个问题,特写了个解决方案,供参考.
问题描述:在Default2.aspx页面中点击按钮将TextBox1控件的值传递到Default3.aspx页面中去,供Default3.aspx页面使用。
关键点有2点:
1、Server.Transfer("Default3.aspx", true); //方法第二个参数为true
2、对于跳转到的页面的头部要添加跳转页面类得引用,<%@ Reference Page="Default2.aspx"%>,如果Default2.aspx在某个文件夹下的话,如Admin文件夹下的话,得这样写:<%@ Reference Page="Admin_Default2.aspx"%>(即是该页面类后台cs文件的完整类名,这个得尤其注意)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string name
{
get
{
return TextBox1.Text;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("Default3.aspx", true);
}
}
==========================================================================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<%@ Reference Page="Default2.aspx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strTxt = "";
Default2 oForm = (Default2)this.Context.Handler;
strTxt += "Default2页面中TextBox1文本框中的值为:" + oForm.name + "<br>";
Response.Write(strTxt);
}
}
}
- Server.Transfer页面跳转传递控件值得解决方案
- 页面跳转 Response.Redirect Server.Transfer Server.Execute
- aspx之间使用Server.Transfer跳转并传递参数
- 页面跳转 Server.Transfer和 Response.Redirect的区别
- asp跳转页面Server的Transfer和Response的Redirect
- JQueryMobile页面跳转参数的传递解决方案
- JQueryMobile页面跳转参数的传递解决方案
- JQueryMobile页面跳转参数的传递解决方案
- JQueryMobile页面跳转参数的传递解决方案
- ASP.NET页面间传递对象 - Server对象的Transfer()
- 使用Server.Transfer在页面之间传递数据
- 使用Server.Transfer在两个ASPX页面间传递参数
- 使用Server.Transfer在两个ASPX页面间传递参数
- Server.Transfer 页面传输
- 页面跳转中Server.Transfer、Server.Execute和Response.Redirect的区别
- {HTML5}JQueryMobile页面跳转参数的传递解决方案
- HTML5 JQueryMobile页面跳转参数的传递解决方案
- {HTML5}JQueryMobile页面跳转参数的传递解决方案
- cognos url方式访问时,如何隐藏URL提升安全性。
- VC中基于Windows 的精确定时_可以精确到微秒
- iPhone UITextField 属性
- char * 转 LPWSTR
- 重新安装Android
- Server.Transfer页面跳转传递控件值得解决方案
- Date和Calendar
- extjs4.0 文件上传
- 广州中国科学院软件应用技术研究所笔经
- (C#)实现时间复杂度为O(n)空间复杂度为O(1)的数组中奇偶数分离
- Ubuntu下RMI Server 抛出java.rmi.ConnectException: Connection refused to host: 127.0.0.1解决办法
- CAN转COM或CAN-1
- 计算机系统层次结构
- WCF基本任务