Showing posts with label page1. Show all posts
Showing posts with label page1. Show all posts

Thursday, March 29, 2012

Passing values between pages

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
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

I have a Page1.htm with the following code:

<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

passing variable from Popup

Whats the best way to pass a variable from a popup to the current page
(without a postback on the current page).
I have a form on 'page1' with various text input boxes. One box contains an
image URL. To select the url , the user can click on a browse button to open
a url chooser pop up ('page2'). I want the url that is selected in 'page2'
to be posted back to 'page1' and displayed in the input box, without losing
the values a user has already input in the other textboxes on page1.
I can use the 'previouspage' method, but I don't think this can work with
popups can it? I don't want the user to lose any of the other textboxes if
they have to browse to the url chooser page then return to the page1.
hopefully that all makes sense.
JJyes or I was using:
btn_browse.Attributes.Add("onclick", "java script:window.open('..etc
"Mark Rae" <mark@.markNOSPAMrae.com> wrote in message
news:uJ5DjU0$GHA.3536@.TK2MSFTNGP03.phx.gbl...
> "JJ" <abc@.xyz.com> wrote in message
> news:eEdelQ0$GHA.4680@.TK2MSFTNGP04.phx.gbl...
>
> When you say 'popup', do you mean you're using showModalDialog...?
>
"JJ" <abc@.xyz.com> wrote in message
news:eEdelQ0$GHA.4680@.TK2MSFTNGP04.phx.gbl...

> Whats the best way to pass a variable from a popup to the current page
> (without a postback on the current page).
When you say 'popup', do you mean you're using showModalDialog...?
Write this code, on click event on button leads to close the popup.
/* Start from here*/
String sURL =’’ // selected url
string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage(‘ + sURL
+’); window.opener.document.forms(0).submit();
self.close();</SCRIPT>";
Page.RegisterClientScriptBlock("ClosePopup", strScript);
/* Ends here*/
Declare the this javascript function SendBackURLTOMainPage(val) in the main
page (aspx)
hdnURL is the hidden variable which store the selected URL from the popup
page.
function SendBackURLTOMainPage (val)
{
document.getElementById("hdnURL").innerText = val;
}
all the best,
Lokesh
"JJ" wrote:

> Whats the best way to pass a variable from a popup to the current page
> (without a postback on the current page).
> I have a form on 'page1' with various text input boxes. One box contains a
n
> image URL. To select the url , the user can click on a browse button to op
en
> a url chooser pop up ('page2'). I want the url that is selected in 'page2'
> to be posted back to 'page1' and displayed in the input box, without losin
g
> the values a user has already input in the other textboxes on page1.
> I can use the 'previouspage' method, but I don't think this can work with
> popups can it? I don't want the user to lose any of the other textboxes if
> they have to browse to the url chooser page then return to the page1.
>
> hopefully that all makes sense.
> JJ
>
>
Thanks Lokesh. But is there any way of doing this in ASP.net rather than
javascript?
"Lokesh Reddy" <Lokesh Reddy@.discussions.microsoft.com> wrote in message
news:662ECFA3-6669-4DC7-97CF-334B00111516@.microsoft.com...
> Write this code, on click event on button leads to close the popup.
> /* Start from here*/
> String sURL ='' // selected url
> string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage(' + sURL
> +'); window.opener.document.forms(0).submit();
> self.close();</SCRIPT>";
> Page.RegisterClientScriptBlock("ClosePopup", strScript);
> /* Ends here*/
>
> Declare the this javascript function SendBackURLTOMainPage(val) in the
> main
> page (aspx)
> hdnURL is the hidden variable which store the selected URL from the popup
> page.
> function SendBackURLTOMainPage (val)
> {
> document.getElementById("hdnURL").innerText = val;
> }
> all the best,
> Lokesh
> "JJ" wrote:
>
Also,
If I wanted to pass the variable into different textboxes, (depending on
which 'browse' button was clicked) is there a way of doing this?
JJ
"JJ" <abc@.xyz.com> wrote in message
news:e0Vl2y0$GHA.1464@.TK2MSFTNGP02.phx.gbl...
> Thanks Lokesh. But is there any way of doing this in ASP.net rather than
> javascript?
> "Lokesh Reddy" <Lokesh Reddy@.discussions.microsoft.com> wrote in message
> news:662ECFA3-6669-4DC7-97CF-334B00111516@.microsoft.com...
>
"JJ" <abc@.xyz.com> wrote in message
news:e0Vl2y0$GHA.1464@.TK2MSFTNGP02.phx.gbl...

> Thanks Lokesh. But is there any way of doing this in ASP.net rather than
> javascript?
No. ASP.NET is server-side, and can't obviously open windows client-side -
you need JavaScript for that.
Ok I've been trying to do this but without success:
I have a button on my urlChooser page:
protected void Button1_OnClick(object sender, System.EventArgs e)
{
String sURL = this.ImageURL_txtbox.Text; // selected url
string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage('" + sURL +
"'); window.opener.document.forms(0).submit();self.close();</SCRIPT>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"ClosePopup",
strScript);
}
and the javascript function in my main page is:
<script type="text/javascript">
function SendBackURLTOMainPage (val)
{
document.getElementById('TextBox1').value=val;
}
</script>
However, the urlChooser page comes up with an error when I click the button,
and the urlChooser window doesn't close. The error says there's an invald
character in this line:
<SCRIPT>window.opener.SendBackURLTOMainPage('/WebSite1/Uploads/XPS1/admin2/C
ivic_photo.gif');
window.opener.document.forms(0).submit();self.close();</SCRIPT>
(forgive me but I'm not too familiar with javascript)
JJ
"Lokesh Reddy" <Lokesh Reddy@.discussions.microsoft.com> wrote in message
news:662ECFA3-6669-4DC7-97CF-334B00111516@.microsoft.com...
> Write this code, on click event on button leads to close the popup.
> /* Start from here*/
> String sURL ='' // selected url
> string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage(' + sURL
> +'); window.opener.document.forms(0).submit();
> self.close();</SCRIPT>";
> Page.RegisterClientScriptBlock("ClosePopup", strScript);
> /* Ends here*/
>
> Declare the this javascript function SendBackURLTOMainPage(val) in the
> main
> page (aspx)
> hdnURL is the hidden variable which store the selected URL from the popup
> page.
> function SendBackURLTOMainPage (val)
> {
> document.getElementById("hdnURL").innerText = val;
> }
> all the best,
> Lokesh
> "JJ" wrote:
>
Found the problem, the single quotes need to be double quotes. Sorry. Still
learning...
"JJ" <abc@.xyz.com> wrote in message
news:ObG8i62$GHA.2328@.TK2MSFTNGP02.phx.gbl...
> Ok I've been trying to do this but without success:
> I have a button on my urlChooser page:
> protected void Button1_OnClick(object sender, System.EventArgs e)
> {
> String sURL = this.ImageURL_txtbox.Text; // selected url
> string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage('" + sURL
> + "'); window.opener.document.forms(0).submit();self.close();</SCRIPT>";
> Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"ClosePopup",
> strScript);
> }
> and the javascript function in my main page is:
> <script type="text/javascript">
> function SendBackURLTOMainPage (val)
> {
> document.getElementById('TextBox1').value=val;
> }
> </script>
>
> However, the urlChooser page comes up with an error when I click the
> button, and the urlChooser window doesn't close. The error says there's an
> invald character in this line:
> <SCRIPT>window.opener.SendBackURLTOMainPage('/WebSite1/Uploads/XPS1/admin2
/Civic_photo.gif');
> window.opener.document.forms(0).submit();self.close();</SCRIPT>
>
> (forgive me but I'm not too familiar with javascript)
>
> JJ
>
>
>
>
>
> "Lokesh Reddy" <Lokesh Reddy@.discussions.microsoft.com> wrote in message
> news:662ECFA3-6669-4DC7-97CF-334B00111516@.microsoft.com...
>