I got one classic asp page and another aspx page. The classic asp page will be the parent page and the aspx page will be the child page. The child page will have a code behind page that update or add the data. The changes after any operation (update/add) will be reflected immediately at the parent page, after the child close via window.close().
I have tried to set hidden variable at the parent page and set the hidden variable at the child page and put it at body onunload event, but it seems not working.
My classic asp page:
if Request.Form="" then
if Request.Form("hidMode") = "Cr" and Request.Form("hidECardID") <> "" then
SuccessMsg = "The ECard ID template is successfully created."
end if
end if
At end of classic asp page (before form tag closing):
<input type="hidden" name="hidMode">
<input type="hidden" name="hidECardID">
My aspx page:
inside head tag:
<script type="text/javascript">
function passVal() {
winObj = window.opener
//alert(window.opener.location.href) //doesn't produce popup
eCardID =<%=hdECardID.Value%>
docMode =<%=hdMode1.Value%>
winObj.document.form1.hidECardID.value = eCardID;
winObj.document.form1.hidMode.value = docMode;
window.opener.document.form1.submit();
window.close()
}
</script>
At body tag:
<body onunload="passVal()">
I've search for answer but mostly is aspx to aspx page. I could use response.redirect, but my issue is this aspx is a pop-up (not an iframe), after user clicked on a button on the classic asp page. Using response.redirect will only open the page inside the pop-up itself, and not refreshing the parent page.
Related
I have an update panel in aspx page.
Click on one of the button show a div from code behind, and load to that div element from another page
ScriptManager.RegisterClientScriptBlock(this.Page, typeof(UpdatePanel), Guid.NewGuid().ToString(),
"UpsalePopup(); $('#MyDiv').load('PopUp/UpsaleAdv.aspx #UpsaleAdvPanel');"
, true);
And its working perfect.
After user close that div (have only picture)
click on asp Button to do function on server side, go to '/UpsaleAdv.aspx' and show it as 404.
Is the load() function ruin my page ? how can I prevent it or solve it ?
The page 'PopUp/UpsaleAdv.aspx' was an aspx page with <form> tag.
And after do this function:
$('#MyDiv').load('PopUp/UpsaleAdv.aspx #UpsaleAdvPanel');"
it makes the current page (myaspa.aspx) to get the funcunality from PopUp/UpsaleAdv.aspx
And once I removed the <form> tag and replaced the page to inherit from master page all works perfect.
I have a page with products and each product has a link: "Buy". After clicking the link, a popup will show up which will have inside another .aspx file embedded. (the popup is generated by Colorbox plugin)
After the user is making the purchase (clicking on the button that sends to the DB information and so on):
1. the popup has to close itself
2. the parent page has to be reloaded
3. the scroll position has to be maintained
The problem is that the scroll position is not maintained (especially in IE browser).
What I tried:
1.
MaintainScrollPositionOnPostback="true" -- had no effect
And:
Popup page:
<script>window.parent.callbackfromchild('" + ID + "');</script>
Parent page:
function callbackfromchild(arg) {
__doPostBack("callbackbtn", "");
window.onload = function () {
document.getElementById('#div' + arg).scrollIntoView(true);
};
What am I doing wrong?
You need this script in parent aspx page
<script>
function callbackfromchild(id) {
//maintain hash on post back
var form = document.getElementById("<%=Page.Form.ClientID%>");
// Change form action & post back
form.action += '#'+ id;
__doPostBack("<%=callbackbtn.ClientID%>", "");
}
</script>
And you need this anchor -with ID to be used a function parameter from popup- placed next to each product with different ids. So when URL of parent page reload with a hash added to it " page.aspx#x1" it will make the browser scrolls to that element.
<a id="x1"></a>
And I guess you already have this Linkbutton on parent page, will be target of postback
<asp:LinkButton ID="callbackbtn" runat="server" />
On colorbox popup you need to pass the anchor Id back to parent
window.parent.callbackfromchild('x1')
Or it that was a popup window , you would call it like this
window.opener.callbackfromchild('x1')
You can put current scroll position into cookie before opening popup and reapply it on window.onload, I use jQuery.scrollTo plugin for such tasks, it works perfect
I have an asp.net application with master page. In one of the pages I have a button click event which opens another page using javascript as shown below.
string urlVerify = "VerifyEnrollmentEntries.aspx";
string fullURLVerify = "var newVerifyDataWindow = window.open('" + urlVerify + "','_blank','height=600,width=950,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=no' );
ClientScript.RegisterStartupScript(this.Page.GetType(), "OpenWindow", fullURLVerify, true);
This popup page doesn't have a master page. This is just a stand alone page, but part of the project. When the user clicks the close button on this popup page, I want to close this page and redirect to a specific page in the asp.net. Right now when the close button is clicked, the page closes and the parent page which caused the popup is shown.
Before closing your popup, execute JS code:
opener.location.href = "YourRedirectUrl.aspx"
It will redirect parent to that URL
I am doing some twitter authentication in classic asp (I know, but I can't change it). What I am doing is opening an authentication page in a popup via jQuery/JS with window.open that handels all of the rest/oauth authentication and then returns to the same page with the oauth keys I need. I would then like to close the popup and fire off some jQuery hide/show events without refreshing the page.
Code to fireoff the popup and authentication script:
jQuery(document).ready(function() {
jQuery("#twitter-button").live("click", function() {
jQuery("#twitter-button").attr("value", "Processing");
jQuery("#twitter-button").removeClass();
jQuery("#twitter-button").addClass("twitter-button-processing");
window.open('authentication.asp','_blank','width=600,height=400');
return false;
});
});
I then have the following code on the same page nested in some ASP for when we are redirected back:
if Session("OAUTH_TOKEN") <> "" And Session("OAUTH_TOKEN_SECRET") <> "" Then
%>
<script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
window.close();
// I'd like to show/hide new buttons on the parent page here
});
</script>
<%
End If
The goal is to change the button with a class of twitter-button-processing displaying none but I can not get it to change in the parent window. I have tried placing jQuery('.twitter-button-processing').hide(); in a jQuery(window).unload() function after the close but this did not produce the correct result.
I tried the solutions from Binding jQuery event on a child window and How to run function of parent window when child window closes? to no avail. Any help would be fantastic.
So I ended up pinpointing the answer on my own. Instead of redirecting back to the same page which was getting messy, I am redirecting to a blank page from the twitter popup window with some classic ASP that checks a few session variables.
Main File
var someFunction = function(data){
//some functionality
}
Twitter Popup Redirect window in the asp checks
window.opener.someFunction();
window.close();
This did exactly what I needed to do by calling the JS on the parent window while closing the child. Maybe this will help someone else.
I have an aspx page with an iFrame. The iFrame's src is set to a child aspx page.
I somehow need to display a modal popup form on the parent aspx page, to be shown when clicking a button on the child aspx page.
Something like:
Function ShowIt()
{
document.parent.getElemtentById("<%= modal.clientID %>").show();
// Or
$parent.find('modal').show();
}
Any ideas would be greatly appreciated!
Thanks,
Jason
Set BehaviorID property value for a ModalPopupExtender and use this script : window.parent.$find('behaviorId').show();