"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:eV******** ******@TK2MSFTN GP15.phx.gbl...
"tshad" <ts**********@f tsolutions.com> wrote in message
news:eX******** ******@TK2MSFTN GP14.phx.gbl...
Is there a way to tell if the window was closed using the "x"
If you look at the demo, when you click one of the links it returns "Yes",
"No" etc into the textbox. When you click the x in the top-right corner,
it returns an empty string into the textbox.
So, I assume the best way to make it work would be to put something in the
textbox and then check if it is empty. If it is, the user pressed the "x"
to close the window.
I am having a problem with using this in an asp.net page using buttons.
I made a change where I pass the title and the name of the textbox to the
function, but otherwise it is the same. Here is the page I am using at the
moment:
*************** *************** *************** *************** *************** *
*
<%@ Page Language="VB" trace="false" debug="true" AutoEventWireup ="true"
ContentType="te xt/html" ResponseEncodin g="iso-8859-1" %>
<!--#include virtual = '/Development/includes/ModalDialogs.in c'-->
<script runat="server">
sub page_load(s as object, e as eventArgs)
if not isPostBack then
Button1.Attribu tes.Add("onclic k", "YesNoCancel('T his is a
test','modalret urn2','Yes, no, or cancel me','YesNoCance lReturnMethod() ');")
end if
end sub
</script>
<form runat="server">
<asp:Button ID="Button1" text="submit" runat="server"/><br>
<input type=text id=modalreturn2 name=modalretur n2 value=''><br>
<a href="javascrip t:YesNoCancel(' This is the first
Title','modalre turn2','Yes, no, or cancel
me','YesNoCance lReturnMethod() ');">Show Modal #1</a>
</form>
<p> </p>
</body>
</html>
*************** *************** *************** *************** **
In this page am calling the javascript popup from a link and a button. With
the link it works everytime I press the link. Once I use the button, it
doesn't work for the link anymore.
For the button, it opens the popup fine, but it never returns when I press
the link on the popup page. It only returns when I press the "x". It never
returns anything from the popup (not even the empty string when pressing the
"x").
At this point, neither the button nor the link will bring up the popup box.
What is the problem here?
Here is the page that is rendered from .aspx:
*************** *************** *************** *************** **************
<script language=JavaSc ript>
var ModalDialogWind ow;
var ModalDialogInte rval;
var ModalDialog = new Object;
ModalDialog.val ue = '';
ModalDialog.eve nthandler = '';
ModalDialog.ret urnAddress = '';
function ModalDialogMain tainFocus()
{
try
{
if (ModalDialogWin dow.closed)
{
window.clearInt erval(ModalDial ogInterval);
eval(ModalDialo g.eventhandler) ;
return;
}
ModalDialogWind ow.focus();
}
catch (everything) { }
}
function ModalDialogRemo veWatch()
{
ModalDialog.val ue = '';
ModalDialog.eve nthandler = '';
}
function ModalDialogShow (Title,ReturnAd dress,BodyText, Buttons,EventHa ndler)
{
alert("this is a test");
ModalDialogRemo veWatch();
ModalDialog.eve nthandler = EventHandler;
ModalDialog.ret urnAddress = ReturnAddress;
var args='width=350 ,height=125,lef t=325,top=300,t oolbar=0,';
args+='location =0,status=0,men ubar=0,scrollba rs=1,resizable= 0';
ModalDialogWind ow=window.open( "","",args) ;
ModalDialogWind ow.document.ope n();
ModalDialogWind ow.document.wri te('<html>');
ModalDialogWind ow.document.wri te('<head>');
ModalDialogWind ow.document.wri te('<style>body {background-color:
#B2CBD2;}</style>')
ModalDialogWind ow.document.wri te('<title>' + Title + '</title>');
ModalDialogWind ow.document.wri te('<script' + ' language=JavaSc ript>');
ModalDialogWind ow.document.wri te('function CloseForm(Respo nse) ');
ModalDialogWind ow.document.wri te('{ ');
ModalDialogWind ow.document.wri te(' window.opener.M odalDialog.valu e =
Response; ');
ModalDialogWind ow.document.wri te(' window.close(); ');
ModalDialogWind ow.document.wri te('} ');
ModalDialogWind ow.document.wri te('</script' + '>');
ModalDialogWind ow.document.wri te('</head>');
ModalDialogWind ow.document.wri te('<body onblur="window. focus();">');
ModalDialogWind ow.document.wri te('<table border=0 width="95%"
align=center cellspacing=0 cellpadding=2>' );
ModalDialogWind ow.document.wri te('<tr><td align=left>' + BodyText +
'</td></tr>');
ModalDialogWind ow.document.wri te('<tr><td align=left><br> </td></tr>');
ModalDialogWind ow.document.wri te('<tr><td align=center>' + Buttons +
'</td></tr>');
ModalDialogWind ow.document.wri te('</body>');
ModalDialogWind ow.document.wri te('</html>');
ModalDialogWind ow.document.clo se();
ModalDialogWind ow.focus();
ModalDialogInte rval = window.setInter val("ModalDialo gMaintainFocus( )",5);
}
</script>
<script language=JavaSc ript>
function YesNoCancel(Tit le,returnAddres s,BodyText,Even tHandler)
{
var Buttons='';
Buttons = '<a href=javascript :CloseForm("Yes ");>Yes</a> ';
Buttons += '<a href=javascript :CloseForm("No" );>No</a> ';
Buttons += '<a href=javascript :CloseForm("Can cel");>Cancel</a> ';
ModalDialogShow (Title,returnAd dress,BodyText, Buttons,EventHa ndler);
}
function YesNoMaybe(Titl e,returnAddress ,BodyText,Event Handler)
{
var Buttons='';
Buttons = '<a
href=javascript :CloseForm("Yes ");>Yes</a> & nbsp; ';
Buttons += '<a
href=javascript :CloseForm("No" );>No</a> & nbsp; ';
Buttons += '<a href=javascript :CloseForm("May be");>Maybe</a> ';
ModalDialogShow (Title,ReturnAd dress,BodyText, Buttons,EventHa ndler);
}
function YesNoCancelRetu rnMethod()
{
document.getEle mentById(ModalD ialog.returnAdd ress).value =
ModalDialog.val ue;
ModalDialogRemo veWatch();
}
function YesNoMaybeRetur nMethod()
{
document.getEle mentById(ModalD ialog.returnAdd ress).value =
ModalDialog.val ue;
ModalDialogRemo veWatch();
}
</script>
<form name="_ctl0" method="post" action="TMP28cy pdoa6c.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTA TE"
value="dDw5NjU1 MTU1O3Q8O2w8aTw xPjs+O2w8dDw7bD xpPDE+Oz47bDx0P HA8O3A8bDxvbmNs a
WNrOz47bDxZZXNO b0NhbmNlbCgnVGh pcyBpcyBhIHRlc3 QnLCdtb2RhbHJld HVybjInLCdZZXMs I
G5vLCBvciBjYW5j ZWwgbWUnLCdZZXN Ob0NhbmNlbFJldH Vybk1ldGhvZCgpJ ylcOzs+Pj47Oz47 P
j47Pj47Pgp4F76k b7VjTMvhPLbWVoJ O6PFw" />
<input type="submit" name="Button1" value="submit" id="Button1"
onclick="YesNoC ancel('This is a test','modalret urn2','Yes, no, or cancel
me','YesNoCance lReturnMethod() ');" /><br>
<input type=text id=modalreturn2 name=modalretur n2 value=''><br>
<a href="javascrip t:YesNoCancel(' This is the first
Title','modalre turn2','Yes, no, or cancel
me','YesNoCance lReturnMethod() ');">Show Modal #1</a>
<input type=hidden name='_sk_scrol lkeepervalue' id='_sk_scrollk eepervalue'
value='0!0'><sc ript>function SKFilter_SetPos ition(){
scrollTo(0,0);} </script><script language='javas cript'>onscroll =
function(){docu ment.getElement ById('_sk_scrol lkeepervalue'). value =
document.body.s crollLeft+'!' + document.body.s crollTop;}</script></form>
<p> </p>
</body>
</html>
*************** *************** *************** *************** **************
Thanks,
Tom