previouspage.findcontrol从previous页面获取变量 [英] previouspage.findcontrol getting variable from previous page

查看:444
本文介绍了previouspage.findcontrol从previous页面获取变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从previous页保留变量的值。我相信这是C#的方式做到这一点,但我想vb.net方式可以有人请帮助:

i am trying to retain the value of a variable from a previous page. i believe this is the C# way to do this, but i would like the vb.net way can someone please help:

TextBox myTxt = (TextBox)Page.PreviousPage.FindControl("previousPageTextBox");   
currentPageTextBox.text = myTxt.Text;

我想知道如何code这个在vb.net

i would like to know how to code this in vb.net

我想这:

Dim myTxt As TextBox = CType(Page.PreviousPage.FindControl("Textbox1"), TextBox)
        TextBox1.Text = myTxt.Text

但我得到这个错误信息:

but i got this error msg:

使用new关键字来创建一个对象实例

use the new keyword to create an object instance

推荐答案

这应该这样做,也请确保您使用Server.Transfer的页之间去..但我相信你已经知道这一点:

This should do it, also make sure you are using Server.Transfer to go between pages.. but I am sure you already know this:

Dim myTxt as TextBox = CType(Page.PreviousPage.FindControl("previousPageTextBox"), TextBox)
currentPageTextBox.text = myTxt.Text

这篇关于previouspage.findcontrol从previous页面获取变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆