473,548 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1890
"JJ" <ab*@xyz.comwro te in message
news:eE******** ******@TK2MSFTN GP04.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.Attr ibutes.Add("onc lick", "javascript:win dow.open('..etc

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:uJ******** ******@TK2MSFTN GP03.phx.gbl...
"JJ" <ab*@xyz.comwro te in message
news:eE******** ******@TK2MSFTN GP04.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.SendBac kURLTOMainPage( ‘ + sURL
+’); window.opener.d ocument.forms(0 ).submit();
self.close();</SCRIPT>";

Page.RegisterCl ientScriptBlock ("ClosePopup ", strScript);
/* Ends here*/
Declare the this javascript function SendBackURLTOMa inPage(val) in the main
page (aspx)
hdnURL is the hidden variable which store the selected URL from the popup
page.

function SendBackURLTOMa inPage (val)
{
document.getEle mentById("hdnUR L").innerTex t = 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***@discussio ns.microsoft.co mwrote in message
news:66******** *************** ***********@mic rosoft.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.SendBac kURLTOMainPage( ' + sURL
+'); window.opener.d ocument.forms(0 ).submit();
self.close();</SCRIPT>";

Page.RegisterCl ientScriptBlock ("ClosePopup ", strScript);
/* Ends here*/
Declare the this javascript function SendBackURLTOMa inPage(val) in the
main
page (aspx)
hdnURL is the hidden variable which store the selected URL from the popup
page.

function SendBackURLTOMa inPage (val)
{
document.getEle mentById("hdnUR L").innerTex t = 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.comwro te in message
news:e0******** ******@TK2MSFTN GP02.phx.gbl...
Thanks Lokesh. But is there any way of doing this in ASP.net rather than
javascript?

"Lokesh Reddy" <Lokesh Re***@discussio ns.microsoft.co mwrote in message
news:66******** *************** ***********@mic rosoft.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.SendBac kURLTOMainPage( ' + sURL
+'); window.opener.d ocument.forms(0 ).submit();
self.close() ;</SCRIPT>";

Page.RegisterC lientScriptBloc k("ClosePopup ", strScript);
/* Ends here*/
Declare the this javascript function SendBackURLTOMa inPage(val) in the
main
page (aspx)
hdnURL is the hidden variable which store the selected URL from the popup
page.

function SendBackURLTOMa inPage (val)
{
document.getEl ementById("hdnU RL").innerTex t = 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.comwro te in message
news:e0******** ******@TK2MSFTN GP02.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.EventArg s e)

{

String sURL = this.ImageURL_t xtbox.Text; // selected url

string strScript = "<SCRIPT>window .opener.SendBac kURLTOMainPage( '" + sURL +
"'); window.opener.d ocument.forms(0 ).submit();self .close();</SCRIPT>";

Page.ClientScri pt.RegisterClie ntScriptBlock(t his.GetType()," ClosePopup",
strScript);

}

and the javascript function in my main page is:

<script type="text/javascript">

function SendBackURLTOMa inPage (val)

{

document.getEle mentById('TextB ox1').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.SendBack URLTOMainPage('/WebSite1/Uploads/XPS1/admin2/Civic_photo.gif ');
window.opener.d ocument.forms(0 ).submit();self .close();</SCRIPT>
(forgive me but I'm not too familiar with javascript)

JJ



"Lokesh Reddy" <Lokesh Re***@discussio ns.microsoft.co mwrote in message
news:66******** *************** ***********@mic rosoft.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.SendBac kURLTOMainPage( ' + sURL
+'); window.opener.d ocument.forms(0 ).submit();
self.close();</SCRIPT>";

Page.RegisterCl ientScriptBlock ("ClosePopup ", strScript);
/* Ends here*/
Declare the this javascript function SendBackURLTOMa inPage(val) in the
main
page (aspx)
hdnURL is the hidden variable which store the selected URL from the popup
page.

function SendBackURLTOMa inPage (val)
{
document.getEle mentById("hdnUR L").innerTex t = 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.comwro te in message
news:Ob******** ******@TK2MSFTN GP02.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.EventArg s e)

{

String sURL = this.ImageURL_t xtbox.Text; // selected url

string strScript = "<SCRIPT>window .opener.SendBac kURLTOMainPage( '" + sURL
+ "'); window.opener.d ocument.forms(0 ).submit();self .close();</SCRIPT>";

Page.ClientScri pt.RegisterClie ntScriptBlock(t his.GetType()," ClosePopup",
strScript);

}

and the javascript function in my main page is:

<script type="text/javascript">

function SendBackURLTOMa inPage (val)

{

document.getEle mentById('TextB ox1').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.SendBack URLTOMainPage('/WebSite1/Uploads/XPS1/admin2/Civic_photo.gif ');
window.opener.d ocument.forms(0 ).submit();self .close();</SCRIPT>
(forgive me but I'm not too familiar with javascript)

JJ



"Lokesh Reddy" <Lokesh Re***@discussio ns.microsoft.co mwrote in message
news:66******** *************** ***********@mic rosoft.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.SendBac kURLTOMainPage( ' + sURL
+'); window.opener.d ocument.forms(0 ).submit();
self.close() ;</SCRIPT>";

Page.RegisterC lientScriptBloc k("ClosePopup ", strScript);
/* Ends here*/
Declare the this javascript function SendBackURLTOMa inPage(val) in the
main
page (aspx)
hdnURL is the hidden variable which store the selected URL from the popup
page.

function SendBackURLTOMa inPage (val)
{
document.getEl ementById("hdnU RL").innerTex t = 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
4332
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) { window1=open("solution.php?folder=folder1&file=file1"); }
6
7073
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 with the related description. This is done and is obviously not a concern. However, now I would like to make it so the corresponding row becomes...
3
3433
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 am wanting to then use this value within an element of a form on the current page -
13
2469
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 Error GoTo err_zoom strFormName = formName
5
2411
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 variables value needs to be passed from the main page to this popup window ... but it isn't. why? the submit button one the PHP page is
5
1728
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 document.getElementById: var variable = document.getElementById('txtBox).value; But if the control is hidden, that javascript code generates an error. Can...
1
3716
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 form fields allow for the item description, fee, etc. I'd like the fee field to be variable based upon which hyperlink launched the popup. So,...
10
11788
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", after the popup closed, then from parent window, we can use alert(var_from_popup) and it will show us the "abc"?
3
2799
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 "player" windows, and as each popup page requires slightly varied object/embed parameters specifying to which Hulu file to link, I've been creating a...
0
7518
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7711
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7954
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7805
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
755
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.