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