473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

passing variable from Popup

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

JJ
Nov 3 '06 #1
8 1880
"JJ" <ab*@xyz.comwrote in message
news:eE**************@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...?
Nov 3 '06 #2
JJ
yes or I was using:
btn_browse.Attributes.Add("onclick", "javascript:window.open('..etc

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uJ**************@TK2MSFTNGP03.phx.gbl...
"JJ" <ab*@xyz.comwrote in message
news:eE**************@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...?

Nov 3 '06 #3

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

JJ
Nov 3 '06 #4
JJ
Thanks Lokesh. But is there any way of doing this in ASP.net rather than
javascript?

"Lokesh Reddy" <Lokesh Re***@discussions.microsoft.comwrote in message
news:66**********************************@microsof t.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:
>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.

JJ

Nov 3 '06 #5
JJ
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" <ab*@xyz.comwrote in message
news:e0**************@TK2MSFTNGP02.phx.gbl...
Thanks Lokesh. But is there any way of doing this in ASP.net rather than
javascript?

"Lokesh Reddy" <Lokesh Re***@discussions.microsoft.comwrote in message
news:66**********************************@microsof t.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:
>>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.

JJ


Nov 3 '06 #6
"JJ" <ab*@xyz.comwrote in message
news:e0**************@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.
Nov 3 '06 #7
JJ
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.clos e();</SCRIPT>";

Page.ClientScript.RegisterClientScriptBlock(this.G etType(),"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.clos e();</SCRIPT>
(forgive me but I'm not too familiar with javascript)

JJ



"Lokesh Reddy" <Lokesh Re***@discussions.microsoft.comwrote in message
news:66**********************************@microsof t.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:
>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.

JJ

Nov 3 '06 #8
JJ
Found the problem, the single quotes need to be double quotes. Sorry. Still
learning....
"JJ" <ab*@xyz.comwrote in message
news:Ob**************@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.clos e();</SCRIPT>";

Page.ClientScript.RegisterClientScriptBlock(this.G etType(),"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.clos e();</SCRIPT>
(forgive me but I'm not too familiar with javascript)

JJ



"Lokesh Reddy" <Lokesh Re***@discussions.microsoft.comwrote in message
news:66**********************************@microsof t.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:
>>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.

JJ


Nov 3 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raju V.K | last post by:
can I use javascript and PHP in the following manner to create a pop-up window: <--- in <head> </head> <script language=javascript> function popup(folder1, file1) {...
6
by: veganeater | last post by:
Hi Everyone, I was wondering if there was a way to pass a variable to a popup window. The purpose is make it so when a user clicks on a specific region/link of the glossary page, a popup opens...
3
by: michael | last post by:
let me keep it clean, quick and simple. I am passing a variable into another window and am reassigning the value on the new page - window.document...value = opener.document. ....value and...
13
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On...
5
by: Steve | last post by:
Hi, I currently have a problem passing a variable value from one page to another. Once a form submit button is pressed java pops up a window and displays some information. The problem being is...
5
by: VMI | last post by:
How can I pass variable or Property values from my popup webForm to the webform that opened this popup? For information that's in a control (i.e. Textbox), I'm using javascript and...
1
by: Wolfman | last post by:
Hi gang! I've been searching for a solution to this problem extensively but nothing really hits the mark. I have a descriptive popup page that contains a PayPal order button. The normal PayPal...
10
by: perhapscwk | last post by:
how to passing value from popup to the parent window as a variable which I can access and process the variable(string) in parent window? such as from popup page, we have var_from_popup="abc",...
3
by: Wolfman | last post by:
Hi guys I thank you for being the most helpful and responsive tech group around, and I have a new one for you. Have you ever embedded Hulu on a page before? I use it quite extensively in popup...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.