两个aspx页面间传递引用对象。
来源:互联网 发布:大一c语言编程题库 编辑:程序博客网 时间:2024/06/05 18:33
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
Server.Transfer替代Response.Redirect就可以。
例子:
-------------In Page A codebehind:
public class PageA : System.Web.UI.Page
{
public System.Web.UI.WebControls.TextBox TextBox1;
public System.Web.UI.WebControls.Button Button1;
// standard page code (Page_Load, etc)
// ....
// ....
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("b.aspx");
}
}
-------------In Page B codebehind:
private void Page_Load(object sender, System.EventArgs e)
{
PageA myAPage = Context.Handler as PageA;
string textboxFromPageA = myAPage.TextBox1.Text;
}
因为当使用Server.Transfer时所有的对象(A and B)在服务器上当时都是活动的,你可以引用任何东西。
稍微修改一下b.aspx(uestc95 提供):
Page myPage =(Page) Context.Handler;
string textboxFromPageA;
textboxFromPageA = ((TextBox)myPage.FindControl("TextBox1")).Text;
这样在A.aspx中就可以正常的使用protected类型的了。
Good Luck!
<
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
有不少文章讨论怎么在两个页面间传递引用,如果你页面上的对象设置为public的话,你就可以传递他们在页面间。在页面间传递是使用Server.Transfer替代Response.Redirect就可以。
例子:
-------------In Page A codebehind:
public class PageA : System.Web.UI.Page
{
public System.Web.UI.WebControls.TextBox TextBox1;
public System.Web.UI.WebControls.Button Button1;
// standard page code (Page_Load, etc)
// ....
// ....
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("b.aspx");
}
}
-------------In Page B codebehind:
private void Page_Load(object sender, System.EventArgs e)
{
PageA myAPage = Context.Handler as PageA;
string textboxFromPageA = myAPage.TextBox1.Text;
}
因为当使用Server.Transfer时所有的对象(A and B)在服务器上当时都是活动的,你可以引用任何东西。
稍微修改一下b.aspx(uestc95 提供):
Page myPage =(Page) Context.Handler;
string textboxFromPageA;
textboxFromPageA = ((TextBox)myPage.FindControl("TextBox1")).Text;
这样在A.aspx中就可以正常的使用protected类型的了。
Good Luck!
<
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 两个aspx页面间传递引用对象
- 两个aspx页面间传递引用对象
- 两个aspx页面间传递引用对象。
- 使用Server.Transfer在两个ASPX页面间传递参数
- 使用Server.Transfer在两个ASPX页面间传递参数
- aspx页面添加引用代码
- android页面间传递对象
- android页面间传递对象
- 两个jsp页面间的数据传递
- 两个页面传递参数
- 在aspx页面引用html页
- 对象的引用传递
- 对象引用传递
- 面向对象 引用传递
- 面向对象 引用传递
- 面向对象,引用传递
- 对象传递和引用
- .net vs2010 视图aspx页面创建控件时出错 未将对象引用设置到对象的实例
- 用PHP实现WEB动态网页静态
- iis 坏掉了,重新安装了以后.netframework 不能用了的解决方法
- 用PHP开发GUI
- 我自己写的自定义Web的上传控件
- 用PHP将数据导入到Foxmail
- 两个aspx页面间传递引用对象。
- 基于PHP与XML的PDF文档生成技术
- [技巧]DataGird的hyper column的url field 绑定两个字段
- 无限级别菜单的实现
- 客户端脚本对中文的验证(javascript)
- PHP实现的功能是显示8条基色色带
- 我的asp.net网站开发经验,欢迎参加讨论。
- 一个ORACLE分页程序,挺实用的.
- 笑望人生,关于IHttpHandler处理图片