471,354 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Transfering data from page to page

Hi,

This may be a very trivial answer but I was wondering if it possible to
have a ASP.NET page and on a user click, it transfers to another page.
Rather than redirecting to the new page, I want to pass some data with
it. I know I can do it using sessions but is it possible doing it in a
different way.

Thanks in advance,
Shahid

Nov 19 '05 #1
1 1548
Shahid,

There are a few different methods depending on what type/length of data you
want to pass to the new page.

One of the simplest is to add the data to the Page.Context object like this:

Page 1:

Dim StringToTransfer As String = "My value to transfer (this could be any
type of object)"
Page.Context.Items.Add("MyKey", StringToTransfer)

Server.Transfer("page2.aspx")

Page 2:

Dim TransferredString As String = Ctype(Page.Context.Items.Item("MyKey"),
String)

Of course it would be more efficient to type the string with:
Page.Context.Items.Item("MyKey").ToString, but I wanted to show that any
object type could be passed within the context object.

One interesting possible drawback to this system is that page two gets
delivered to the client machine without the client receiving a redirect, so
the client's address will still read page1.aspx. Most of the time this isn't
an issue.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Shahid Juma" <sh*********@gmail.com> wrote in message
news:11********************@g47g2000cwa.googlegrou ps.com...
Hi,

This may be a very trivial answer but I was wondering if it possible to
have a ASP.NET page and on a user click, it transfers to another page.
Rather than redirecting to the new page, I want to pass some data with
it. I know I can do it using sessions but is it possible doing it in a
different way.

Thanks in advance,
Shahid

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by bernardpace | last post: by
2 posts views Thread by Piotr Karwatka | last post: by
1 post views Thread by suneet.taparia | last post: by
nomad
reply views Thread by nomad | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.