如何将一个页面的值传递给另一个页面 [英] How to pass value of one page to another page

查看:109
本文介绍了如何将一个页面的值传递给另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




在我的第一页上,我有一个功能,它会获得一个新的ID值,需要立即转移到另一个
。我希望使用Request.form(" txtID")在第二页中获得
,但是没有
工作,返回的值是


任何人都知道如何在第一页上正确设置此值,以便让第二页

页面抓住它?我不想使用查询字符串来传递这个值!


提前致谢!

基思

解决方案

这是另一种将值从一个页面传递到另一个页面的简单方法:

(VB.NET代码)


''在传输之前将数据添加到上下文对象

Context.Items(" myParameter")= x

Server.Transfer(" handle_error.aspx ")


然后,在handle_error.aspx.aspx中:


''从上下文属性中获取数据

Dim x as Integer = CType(Context.Items(" myParameter"),Integer)


当然,有很多方法可以将值从一个页面传递到另一个页面

除了查询字符串还有cookie,会话,上下文,保存到每个页面之间数据库中的

临时表等。

你'我们必须决定哪种技术最适合您的应用。


以下是关于此主题的更多好文章:
http:// SteveOrr。 net / faq / PassValues.aspx
http:/ /www.aspalliance.com/kenc/passval.aspx
http://msdn.microsoft.com/msdnmag/is...e/default.aspx


-

我希望这会有所帮助,

Steve C. Orr,MCSD,MVP
http://SteveOrr.net

" Rabbit" < a@a.com>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP04.phx.gbl ...



在我的第一页上,我有一个功能,它会获得一个新的ID值,需要立即转移到另一个。

我想进入第二个页面使用Request.form(" txtID"),但不起作用,返回的值是"

任何人都知道如何在第一页上正确设置此值,为了让第二页抓住它?我不想使用查询字符串来传递这个值!

提前致谢!
基思



除了Steve枚举的所有方法之外,在2.0中还有一个名为跨页面发布的新功能,其中你的表单和它的值

被发布到后续页面。 HTH


Jose

" Rabbit" < a@a.com>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP04.phx.gbl ...



在我的第一页上,我有一个功能,它会获得一个新的ID值,需要立即转移到另一个。

我想进入第二个页面使用Request.form(" txtID"),但不起作用,返回的值是"

任何人都知道如何在第一页上正确设置此值,为了让第二页抓住它?我不想使用查询字符串来传递这个值!

提前致谢!
基思



谢谢史蒂夫


它工作正常,但我有另一个问题,如果用户点击我的SiteMapNode

跳转到另一个页面,因为菜单项是超链接,所以我不能使用

你建议的方法将数据传递到另一页


如果我不能使用Cookies,会话,我不要使用

数据库不需要太多工作。您可以通过点击源页面上的超链接告诉我将数据传递到另一页的任何其他方法吗?


提前致谢


" Steve C. Orr [MVP,MCSD]" <圣*** @ Orr.net>在消息中写道

新闻:好的************** @ TK2MSFTNGP03.phx.gbl ...

这是另一个将值从一个页面传递到另一个页面的简单方法:
(VB.NET代码)

''在传输之前将数据添加到上下文对象
Context.Items(" ; myParameter")= x
Server.Transfer(" handle_error.aspx")

然后,在handle_error.aspx.aspx中:

''抓住来自上下文属性的数据
Dim x as Integer = CType(Context.Items(" myParameter"),Integer)

当然有很多方法可以从一个页面传递值另外
除了查询字符串还有cookie,会话,上下文,保存到每个页面之间的数据库中的临时表等。
你必须决定哪种技术最适合您的应用。

以下是关于此主题的更多好文章:
http://SteveOrr.net/faq/PassValues.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

-
我希望这会有所帮助,
Steve C. Orr,MCSD,MVP
http://SteveOrr.net

" Rabbit" < a@a.com>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP04.phx.gbl ...



在我的第一页上,我有一个功能,它会获得一个新的ID值,需要立即转移到另一个。

我希望在第二页使用Request获取。 form(txtID),但不起作用,返回的值是"

任何人都知道如何在第一页上正确设置此值,以便让第二页抓住它?我不想使用查询字符串来传递这个值!

提前致谢!
Keith




Hi,

On my 1st page, i have a function which gets a new ID value and need to
transfer to another immediately.

which I want to get in 2nd page using Request.form("txtID"), but doesn''t
work, the returned value is ""

Anybody know how to set this value on 1st page properly, in order to let 2nd
page catch it? I don''t want to use querystring to pass this value!

Thanks in advance!
Keith

解决方案

Here''s another nice, simple way to pass values from one page to another:
(VB.NET code)

''Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("handle_error.aspx ")

Then, in handle_error.aspx.aspx:

''Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to another
besides the querystring there are cookies, session, context, saving to a
temporary table in the database between each page, etc.
You''ll have to decide which technique is best for your application.

Here are more good articles on the subject:
http://SteveOrr.net/faq/PassValues.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Rabbit" <a@a.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...

Hi,

On my 1st page, i have a function which gets a new ID value and need to
transfer to another immediately.

which I want to get in 2nd page using Request.form("txtID"), but doesn''t
work, the returned value is ""

Anybody know how to set this value on 1st page properly, in order to let
2nd page catch it? I don''t want to use querystring to pass this value!

Thanks in advance!
Keith



In addition to all of the methods that Steve enumerated, in 2.0 there is a
new feature called cross-page posting where your form and the values of it
get posted to a subsequent page. HTH

Jose
"Rabbit" <a@a.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...

Hi,

On my 1st page, i have a function which gets a new ID value and need to
transfer to another immediately.

which I want to get in 2nd page using Request.form("txtID"), but doesn''t
work, the returned value is ""

Anybody know how to set this value on 1st page properly, in order to let
2nd page catch it? I don''t want to use querystring to pass this value!

Thanks in advance!
Keith



Thanks Steve

Its working, but I have another problem, if the user clicks my SiteMapNode
to jump to another page, since the menu item is hyperlink, so i can''t use
your suggested method to pass data to another page

If I can''t use Cookies, session, and i don''t want too much work by using
database. Any other method you can tell me for pass data to another page by
clicking hyperlink on the source page?

Thanks in advance

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:OK**************@TK2MSFTNGP03.phx.gbl...

Here''s another nice, simple way to pass values from one page to another:
(VB.NET code)

''Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("handle_error.aspx ")

Then, in handle_error.aspx.aspx:

''Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another
besides the querystring there are cookies, session, context, saving to a
temporary table in the database between each page, etc.
You''ll have to decide which technique is best for your application.

Here are more good articles on the subject:
http://SteveOrr.net/faq/PassValues.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Rabbit" <a@a.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...

Hi,

On my 1st page, i have a function which gets a new ID value and need to
transfer to another immediately.

which I want to get in 2nd page using Request.form("txtID"), but doesn''t
work, the returned value is ""

Anybody know how to set this value on 1st page properly, in order to let
2nd page catch it? I don''t want to use querystring to pass this value!

Thanks in advance!
Keith




这篇关于如何将一个页面的值传递给另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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