KAMMIE Don't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution.
when you use window.onload, it will be called even before the Label control is created, so in the function it won't even get the control to assign the value. You would get a null reference when you try to access the control. If you were to use window.onload,
you need to place that in the bottom of the aspx page, not in the head section.
Better way is to use onload event of the body section, which will call once all the controls are rendered.
<body onload="getEmail();">
Hope it helps.
KAMMIE Don't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution.
Marked as answer by azharrahi on Mar 28, 2009 10:58 AM
Well I reloaded the parent page from pop up before. but that must be changed now.
I want after pop up closed, the parent page must not be reloaded from pop up. I can do it simply by removing window.opener.location.href = ......
Now I want to save the state of the page after the pop up is opened and closed, including ViewState. But again I want to refresh the page with same ViewStates. How is it possible?
One more thing can I save the variable value in javascript in parent page before and after pop up opened and closed?
I have resolved this issue. Now the pop up is being closed.
I write
azharrahi
window.opener.location.reload();
after window.close, and it worked.
Please help me regarding other two issues. one is warning message window and 2nd is how to preserve the variable value using javascript on parent window after opening, processing and closing of pop up.
If you mean the confirmation dialog that informs the user that something is closing the window, you can try this bit of code, but it will not work on newer browsers such as Firefox 3.0 as it is a security violation to close a window like you are doing.
azharrahi
Member
127 Points
238 Posts
label and hidden value is not set in pop up from parent window
Mar 27, 2009 05:35 PM|LINK
Here is the javascript function in parent to open pop up
function ShowPopUp() { if(EmailID != null && EmailID != "" ) { Email = EmailID; //alert(EmailID); newwindow = window.open('AdminUpdatePassword.aspx?Email=' + EmailID +'&FirstName=' + FirstName +'&LastName=' + LastName +'&PhoneNo=' + PhoneNo +'&Index=' + Index + '&PageIndex=' + PageIndex,'_blank','height=145,width=375,status=0,location=0,resizable=0,top=300,left=350'); newwindow.focus(); } else { alert("The password can only be changed if the Login ID of the user exists."); } return false; }and here is another js function to return Email from parent window to pop up.
function getEmail() { return Email; }Now the pop up js function get Email is:
function getEmailID() { var Email; Email = window.opener.getEmail(); alert(Email); document.getElementById("lblEmail").innerText = Email; }Now the problem is that... the lblEmail label does not set.... even I use innerHTML but in vein. I also tried to set label on page load usingPage.RegisterClientScriptBlock("Email",lblEmail.Text = "<script>getEmailID();</script>");
tell me the way to set it.also I try to set hidden value but not set. I dont know why this is happening.
I can do it using querystring, but that is not required.
kammie
Contributor
2163 Points
352 Posts
Re: label and hidden value is not set in pop up from parent window
Mar 27, 2009 05:59 PM|LINK
First, you need to call the javascript function in the onload event of the body....like this....
<body onload="getEmail();"...>
then use this....
document.getElementById('<%= lblEmail.ClientID %>').innerHTML = Email;Don't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution.
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: label and hidden value is not set in pop up from parent window
Mar 27, 2009 06:05 PM|LINK
Try:
document.getElementById("lblEmail").innerHTML = '<%= Request["Email"] %>';
NC...
kammie
Contributor
2163 Points
352 Posts
Re: label and hidden value is not set in pop up from parent window
Mar 27, 2009 06:07 PM|LINK
when you use window.onload, it will be called even before the Label control is created, so in the function it won't even get the control to assign the value. You would get a null reference when you try to access the control. If you were to use window.onload, you need to place that in the bottom of the aspx page, not in the head section.
Better way is to use onload event of the body section, which will call once all the controls are rendered.
<body onload="getEmail();">
Hope it helps.
Don't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution.
azharrahi
Member
127 Points
238 Posts
Re: label and hidden value is not set in pop up from parent window
Mar 28, 2009 11:07 AM|LINK
Thanks. It really worked. I resolved the issue.
Well I reloaded the parent page from pop up before. but that must be changed now.
I want after pop up closed, the parent page must not be reloaded from pop up. I can do it simply by removing window.opener.location.href = ......
Now I want to save the state of the page after the pop up is opened and closed, including ViewState. But again I want to refresh the page with same ViewStates. How is it possible?
One more thing can I save the variable value in javascript in parent page before and after pop up opened and closed?
azharrahi
Member
127 Points
238 Posts
Re: label and hidden value is not set in pop up from parent window
Mar 28, 2009 12:23 PM|LINK
well I have used
window.opener.location.reload();
on pop up before closing it. now it refreshes parent page and save the state of the page.
but after that I try to close the pop up, but it does not close
if(window.opener.progressWindow) { window.opener.progressWindow.close(); } window.close();the pop up is not closing now!!!!!!! why ?one more thing is irritating. when the parent page is reloaded, it displays a message
'The page cannot be refreshed without resending the information.
Click try to resend the information again,
or click cancel to return to the page that you were trying to view the page.'
and there are two buttons 'Retry' and 'Cancel' below that message. I hope many people see this message while try to refresh their browser.
I want to block this message. How it is possible
azharrahi
Member
127 Points
238 Posts
Re: label and hidden value is not set in pop up from parent window
Mar 28, 2009 01:20 PM|LINK
I have resolved this issue. Now the pop up is being closed.
I write
after window.close, and it worked.
Please help me regarding other two issues. one is warning message window and 2nd is how to preserve the variable value using javascript on parent window after opening, processing and closing of pop up.
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: label and hidden value is not set in pop up from parent window
Mar 30, 2009 11:38 AM|LINK
If you mean the confirmation dialog that informs the user that something is closing the window, you can try this bit of code, but it will not work on newer browsers such as Firefox 3.0 as it is a security violation to close a window like you are doing.
<script type="text/javascript">
<!--
function closeWindow()
{
window.open('', '_parent');
window.close();
}
// -->
</script>
Also, what variable value are you trying to preserve? If it is an ASP:Label, there is no way. Use a TextBox or hidden element instead.
NC...