T
tshad
This is from my previous post, but a different issue.
I have the following Javascript routine that opens a popup page, but doesn't
seem to work if called from an asp.net button. It seems to work fine from a
link.
The button does bring up the popup window, but when I press the links on the
page, it doesn't return or close the window.
****************************************************************************
*
<%@ Page Language="VB" trace="false" debug="true" AutoEventWireup="true"
ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!--#include virtual = '/Development/includes/ModalDialogs.inc'-->
<script runat="server">
sub page_load(s as object, e as eventArgs)
if not isPostBack then
Button1.Attributes.Add("onclick", "YesNoCancel('This is a
test','modalreturn2', 'Yes, no, or cancel me',
'YesNoCancelReturnMethod()');")
end if
end sub
</script>
<form runat="server">
<asp:Button ID="Button1" text="submit" runat="server"/><br>
<input type=text id=modalreturn2 name=modalreturn2 value=''><br>
<a href="javascript:YesNoCancel('This is the first Title', 'modalreturn2',
'Yes, no, or cancel me', 'YesNoCancelReturnMethod()');" >Show Modal #1</a>
</form>
</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.
Does anyone know what the is the problem here?
Here is the page that is rendered from .aspx:
**************************************************************************
<script language=JavaScript>
var ModalDialogWindow;
var ModalDialogInterval;
var ModalDialog = new Object;
ModalDialog.value = '';
ModalDialog.eventhandler = '';
ModalDialog.returnAddress = '';
function ModalDialogMaintainFocus()
{
try
{
if (ModalDialogWindow.closed)
{
window.clearInterval(ModalDialogInterval);
eval(ModalDialog.eventhandler);
return;
}
ModalDialogWindow.focus();
}
catch (everything) { }
}
function ModalDialogRemoveWatch()
{
ModalDialog.value = '';
ModalDialog.eventhandler = '';
}
function ModalDialogShow(Title,ReturnAddress,BodyText,Buttons,EventHandler)
{
alert("this is a test");
ModalDialogRemoveWatch();
ModalDialog.eventhandler = EventHandler;
ModalDialog.returnAddress = ReturnAddress;
var args='width=350,height=125,left=325,top=300,toolbar=0,';
args+='location=0,status=0,menubar=0,scrollbars=1,resizable=0';
ModalDialogWindow=window.open("","",args);
ModalDialogWindow.document.open();
ModalDialogWindow.document.write('<html>');
ModalDialogWindow.document.write('<head>');
ModalDialogWindow.document.write('<style>body{background-color:
#B2CBD2;}</style>')
ModalDialogWindow.document.write('<title>' + Title + '</title>');
ModalDialogWindow.document.write('<script' + ' language=JavaScript>');
ModalDialogWindow.document.write('function CloseForm(Response) ');
ModalDialogWindow.document.write('{ ');
ModalDialogWindow.document.write(' window.opener.ModalDialog.value =
Response; ');
ModalDialogWindow.document.write(' window.close(); ');
ModalDialogWindow.document.write('} ');
ModalDialogWindow.document.write('</script' + '>');
ModalDialogWindow.document.write('</head>');
ModalDialogWindow.document.write('<body onblur="window.focus();">');
ModalDialogWindow.document.write('<table border=0 width="95%"
align=center cellspacing=0 cellpadding=2>');
ModalDialogWindow.document.write('<tr><td align=left>' + BodyText +
'</td></tr>');
ModalDialogWindow.document.write('<tr><td align=left><br></td></tr>');
ModalDialogWindow.document.write('<tr><td align=center>' + Buttons +
'</td></tr>');
ModalDialogWindow.document.write('</body>');
ModalDialogWindow.document.write('</html>');
ModalDialogWindow.document.close();
ModalDialogWindow.focus();
ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);
}
</script>
<script language=JavaScript>
function YesNoCancel(Title,returnAddress,BodyText,EventHandler)
{
var Buttons='';
Buttons = '<a href=javascript:CloseForm("Yes");>Yes</a> ';
Buttons += '<a href=javascript:CloseForm("No");>No</a> ';
Buttons += '<a href=javascript:CloseForm("Cancel");>Cancel</a> ';
ModalDialogShow(Title,returnAddress,BodyText,Buttons,EventHandler);
}
function YesNoMaybe(Title,returnAddress,BodyText,EventHandler)
{
var Buttons='';
Buttons = '<a
href=javascript:CloseForm("Yes");>Yes</a> ';
Buttons += '<a
href=javascript:CloseForm("No");>No</a> ';
Buttons += '<a href=javascript:CloseForm("Maybe");>Maybe</a> ';
ModalDialogShow(Title,ReturnAddress,BodyText,Buttons,EventHandler);
}
function YesNoCancelReturnMethod()
{
document.getElementById(ModalDialog.returnAddress).value =
ModalDialog.value;
ModalDialogRemoveWatch();
}
function YesNoMaybeReturnMethod()
{
document.getElementById(ModalDialog.returnAddress).value =
ModalDialog.value;
ModalDialogRemoveWatch();
}
</script>
<form name="_ctl0" method="post" action="TMP28cypdoa6c.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTATE"
value="dDw5NjU1MTU1O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+Oz47bDx0PHA8O3A8bDxvbmNsa
WNrOz47bDxZZXNOb0NhbmNlbCgnVGhpcyBpcyBhIHRlc3QnLCdtb2RhbHJldHVybjInLCdZZXMsI
G5vLCBvciBjYW5jZWwgbWUnLCdZZXNOb0NhbmNlbFJldHVybk1ldGhvZCgpJylcOzs+Pj47Oz47P
j47Pj47Pgp4F76kb7VjTMvhPLbWVoJO6PFw" />
<input type="submit" name="Button1" value="submit" id="Button1"
onclick="YesNoCancel('This is a test','modalreturn2','Yes, no, or cancel
me','YesNoCancelReturnMethod()');" /><br>
<input type=text id=modalreturn2 name=modalreturn2 value=''><br>
<a href="javascript:YesNoCancel('This is the first
Title','modalreturn2','Yes, no, or cancel
me','YesNoCancelReturnMethod()');">Show Modal #1</a>
<input type=hidden name='_sk_scrollkeepervalue' id='_sk_scrollkeepervalue'
value='0!0'><script>function SKFilter_SetPosition(){
scrollTo(0,0);}</script><script language='javascript'>onscroll =
function(){document.getElementById('_sk_scrollkeepervalue').value =
document.body.scrollLeft+'!' + document.body.scrollTop;}</script></form>
<p> </p>
</body>
</html>
**************************************************************************
Thanks,
Tom
I have the following Javascript routine that opens a popup page, but doesn't
seem to work if called from an asp.net button. It seems to work fine from a
link.
The button does bring up the popup window, but when I press the links on the
page, it doesn't return or close the window.
****************************************************************************
*
<%@ Page Language="VB" trace="false" debug="true" AutoEventWireup="true"
ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!--#include virtual = '/Development/includes/ModalDialogs.inc'-->
<script runat="server">
sub page_load(s as object, e as eventArgs)
if not isPostBack then
Button1.Attributes.Add("onclick", "YesNoCancel('This is a
test','modalreturn2', 'Yes, no, or cancel me',
'YesNoCancelReturnMethod()');")
end if
end sub
</script>
<form runat="server">
<asp:Button ID="Button1" text="submit" runat="server"/><br>
<input type=text id=modalreturn2 name=modalreturn2 value=''><br>
<a href="javascript:YesNoCancel('This is the first Title', 'modalreturn2',
'Yes, no, or cancel me', 'YesNoCancelReturnMethod()');" >Show Modal #1</a>
</form>
</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.
Does anyone know what the is the problem here?
Here is the page that is rendered from .aspx:
**************************************************************************
<script language=JavaScript>
var ModalDialogWindow;
var ModalDialogInterval;
var ModalDialog = new Object;
ModalDialog.value = '';
ModalDialog.eventhandler = '';
ModalDialog.returnAddress = '';
function ModalDialogMaintainFocus()
{
try
{
if (ModalDialogWindow.closed)
{
window.clearInterval(ModalDialogInterval);
eval(ModalDialog.eventhandler);
return;
}
ModalDialogWindow.focus();
}
catch (everything) { }
}
function ModalDialogRemoveWatch()
{
ModalDialog.value = '';
ModalDialog.eventhandler = '';
}
function ModalDialogShow(Title,ReturnAddress,BodyText,Buttons,EventHandler)
{
alert("this is a test");
ModalDialogRemoveWatch();
ModalDialog.eventhandler = EventHandler;
ModalDialog.returnAddress = ReturnAddress;
var args='width=350,height=125,left=325,top=300,toolbar=0,';
args+='location=0,status=0,menubar=0,scrollbars=1,resizable=0';
ModalDialogWindow=window.open("","",args);
ModalDialogWindow.document.open();
ModalDialogWindow.document.write('<html>');
ModalDialogWindow.document.write('<head>');
ModalDialogWindow.document.write('<style>body{background-color:
#B2CBD2;}</style>')
ModalDialogWindow.document.write('<title>' + Title + '</title>');
ModalDialogWindow.document.write('<script' + ' language=JavaScript>');
ModalDialogWindow.document.write('function CloseForm(Response) ');
ModalDialogWindow.document.write('{ ');
ModalDialogWindow.document.write(' window.opener.ModalDialog.value =
Response; ');
ModalDialogWindow.document.write(' window.close(); ');
ModalDialogWindow.document.write('} ');
ModalDialogWindow.document.write('</script' + '>');
ModalDialogWindow.document.write('</head>');
ModalDialogWindow.document.write('<body onblur="window.focus();">');
ModalDialogWindow.document.write('<table border=0 width="95%"
align=center cellspacing=0 cellpadding=2>');
ModalDialogWindow.document.write('<tr><td align=left>' + BodyText +
'</td></tr>');
ModalDialogWindow.document.write('<tr><td align=left><br></td></tr>');
ModalDialogWindow.document.write('<tr><td align=center>' + Buttons +
'</td></tr>');
ModalDialogWindow.document.write('</body>');
ModalDialogWindow.document.write('</html>');
ModalDialogWindow.document.close();
ModalDialogWindow.focus();
ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);
}
</script>
<script language=JavaScript>
function YesNoCancel(Title,returnAddress,BodyText,EventHandler)
{
var Buttons='';
Buttons = '<a href=javascript:CloseForm("Yes");>Yes</a> ';
Buttons += '<a href=javascript:CloseForm("No");>No</a> ';
Buttons += '<a href=javascript:CloseForm("Cancel");>Cancel</a> ';
ModalDialogShow(Title,returnAddress,BodyText,Buttons,EventHandler);
}
function YesNoMaybe(Title,returnAddress,BodyText,EventHandler)
{
var Buttons='';
Buttons = '<a
href=javascript:CloseForm("Yes");>Yes</a> ';
Buttons += '<a
href=javascript:CloseForm("No");>No</a> ';
Buttons += '<a href=javascript:CloseForm("Maybe");>Maybe</a> ';
ModalDialogShow(Title,ReturnAddress,BodyText,Buttons,EventHandler);
}
function YesNoCancelReturnMethod()
{
document.getElementById(ModalDialog.returnAddress).value =
ModalDialog.value;
ModalDialogRemoveWatch();
}
function YesNoMaybeReturnMethod()
{
document.getElementById(ModalDialog.returnAddress).value =
ModalDialog.value;
ModalDialogRemoveWatch();
}
</script>
<form name="_ctl0" method="post" action="TMP28cypdoa6c.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTATE"
value="dDw5NjU1MTU1O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+Oz47bDx0PHA8O3A8bDxvbmNsa
WNrOz47bDxZZXNOb0NhbmNlbCgnVGhpcyBpcyBhIHRlc3QnLCdtb2RhbHJldHVybjInLCdZZXMsI
G5vLCBvciBjYW5jZWwgbWUnLCdZZXNOb0NhbmNlbFJldHVybk1ldGhvZCgpJylcOzs+Pj47Oz47P
j47Pj47Pgp4F76kb7VjTMvhPLbWVoJO6PFw" />
<input type="submit" name="Button1" value="submit" id="Button1"
onclick="YesNoCancel('This is a test','modalreturn2','Yes, no, or cancel
me','YesNoCancelReturnMethod()');" /><br>
<input type=text id=modalreturn2 name=modalreturn2 value=''><br>
<a href="javascript:YesNoCancel('This is the first
Title','modalreturn2','Yes, no, or cancel
me','YesNoCancelReturnMethod()');">Show Modal #1</a>
<input type=hidden name='_sk_scrollkeepervalue' id='_sk_scrollkeepervalue'
value='0!0'><script>function SKFilter_SetPosition(){
scrollTo(0,0);}</script><script language='javascript'>onscroll =
function(){document.getElementById('_sk_scrollkeepervalue').value =
document.body.scrollLeft+'!' + document.body.scrollTop;}</script></form>
<p> </p>
</body>
</html>
**************************************************************************
Thanks,
Tom