Thursday, March 29, 2012
Passing values between pages
I need to move from page1 to page2 but I also need to pass a string value
between the two. Is there a way to achieve this?
Thanks
Regardsquerystring
- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
"John" <John@.nospam.infovis.co.uk> wrote in message
news:%23iWf5$WrEHA.3988@.tk2msftngp13.phx.gbl...
> Hi
> I need to move from page1 to page2 but I also need to pass a string value
> between the two. Is there a way to achieve this?
> Thanks
> Regards
>
This was asked and answered here the other day. Here's a part of the respons
e
from Steve Orr:
http://msdn.microsoft.com/msdnmag/i...te/default.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://www.dotnetjunkies.com/tutori...?tutorialid=600
http://www.dotnetbips.com/displayarticle.aspx?id=79
Here's one nice, simple way to pass values from one page to another:
'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")
Then, in WebForm2.aspx:
'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)
"John" wrote:
> Hi
> I need to move from page1 to page2 but I also need to pass a string value
> between the two. Is there a way to achieve this?
> Thanks
> Regards
>
>
You can use a Session variable.
Xavier Pacheco
Xapware Technologies Inc
manage your projects: www.xapware.com/ActiveFocus.htm
the blog: www.xavierpacheco.com/xlog
the book: www.amazon.com/exec/obidos/ASIN/067...avierpacheco-20
Umm .. be careful when you use Session variables though - sticking
everything under the sun into session variables is not the most desirable
thing to do; from a scaleability point of view.
- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
"Xavier Pacheco" <xavier@._nospam_xapware.com> wrote in message
news:xn0do9v4d9ymlpx00f@.msnews.microsoft.com...
> You can use a Session variable.
>
> --
> Xavier Pacheco
> Xapware Technologies Inc
> manage your projects: www.xapware.com/ActiveFocus.htm
> the blog: www.xavierpacheco.com/xlog
> the book: www.amazon.com/exec/obidos/ASIN/067...avierpacheco-20
very true indeed.
Xavier Pacheco
Xapware Technologies Inc
manage your projects: www.xapware.com/ActiveFocus.htm
the blog: www.xavierpacheco.com/xlog
the book: www.amazon.com/exec/obidos/ASIN/067...avierpacheco-20
Monday, March 26, 2012
Passing values from one page to another
<HTML>
<frameset cols="40%,*" >
<frame name="LeftFrame" src='Page2.aspx?Table=??' >
<frame name="RightFrame" >
</frameset>
</HTML
Page1.htm was called using Page1.htm?Table=Users.
I don't know the syntax of how to pass the value of the parameter "Table" onto the second page I'm loading on the LeftFrame, using request.querystring( "Table" ).
I apprecciate any help.
Mosheuse the following:
<frame name="LeftFrame" src='Page2.aspx?Table=<% Response.Write(Request.QueryString("Table"));%>'
Moshe & Sachin
Thanks for your contribution Sachin but the suggestion will not work as it basically an static HTM page as Moshe wrote "I have a Page1.htm with ..." Therfore Response.Write(Request.QueryString("Table")) can't be performed there! An static page would not be able to process this directive. However, the frame file Page2.aspx is able to process all server side code like a normal ASP.NET page.
If you go like src='Page2.aspx?Table=myTable', this will do as its an static parameter. However you can always parse this using java script (it works in static HTML). Try this article
http://www.eggheadcafe.com/articles/20020107.asp
OR make page1.htm (main page) a webform (aspx file) i.e. page1.aspx and this will do as well.
Hope it helps.
-Adnan Masood
Sachin & Adnan,
Thanks very much for the information.
For now I'm implementing the solution keeping Page1.htm as it is and not as a web form, I went to the article Adnan recommended and I already have a function called "queryString()" that is working and returning the value for the parameter "Table" correctly.
Please tell me how to insert the value returned by the javascript function "queryString()" in the code:
<frame name="LeftFrame" src='Page2.aspx?Table=??'
Thanks,
Moshe