I posted this on the asp.net group, also. I wasn't sure whether this was an
asp.net problem or a javascript problem.
I have a page that was originally created from a program I found on the net
that works well as an html page.
It brings up a modal popup window that I have been trying to work out for
days now and this was the closest I have been able to come.
I added a little asp.net code and an asp.net button and cannot get it to
work with that button. It seems to break the javascript code.
The page works fine with or without the asp.net code (as long as the asp.net
button is not pushed).
This works fine (as before) until I press the asp.net button. I am opening
alert boxes in various locations that all fire until the asp.net button is
pushed. From that time, all links and buttons will bring up the alert box
in the first javascript funtion, but the ModalDialogShow never gets called
or it just ignores it and therefore the popup window never gets called.
Why would the asp.net button cause the Javascript to quit functioning?
Why does the popup window not close when the buttons or links are pressed on
them?
*************** *************** *************** *************** *************** ***********
<%@ Page Language="VB" trace="false" debug="true" AutoEventWireup ="true"
ContentType="te xt/html" ResponseEncodin g="iso-8859-1" %>
<html>
<script language=JavaSc ript>
var ModalDialogWind ow;
var ModalDialogInte rval;
var ModalDialog = new Object;
ModalDialog.val ue = '';
ModalDialog.eve nthandler = '';
function ModalDialogMain tainFocus()
{
try
{
if (ModalDialogWin dow.closed)
{
alert("at ModalDialogWind ow.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,BodyText ,Buttons,EventH andler)
{
alert("inside ModalDialogShow ");
ModalDialogRemo veWatch();
ModalDialog.eve nthandler = EventHandler;
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('<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(Bod yText,EventHand ler)
{
alert("inside YesNoCancel")
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> ';
Buttons = '<BUTTON onclick="javasc ript:CloseForm( \'Yes\');"
type="button">Y es</BUTTON> ';
Buttons += '<BUTTON onclick="javasc ript:CloseForm( \'No\');" type =
"button">No </BUTTON> ';
Buttons += '<BUTTON onclick="javasc ript:CloseForm( \'Cancel\');" type =
"button">Cancel </BUTTON> ';
ModalDialogShow ("Dialog",BodyT ext,Buttons,Eve ntHandler);
}
function YesNoMaybe(Body Text,EventHandl er)
{
var Buttons='';
Buttons = '<a href=javascript :CloseForm("Yes ");>Yes</a> ';
Buttons += '<a href=javascript :CloseForm("No" );>No</a> ';
Buttons += '<a href=javascript :CloseForm("May be");>Maybe</a> ';
ModalDialogShow ("Dialog",BodyT ext,Buttons,Eve ntHandler);
}
function YesNoCancelRetu rnMethod()
{
alert("inside YesNoCancelRetu rnMethod");
document.getEle mentById('modal return1').value = ModalDialog.val ue;
ModalDialogRemo veWatch();
}
function YesNoMaybeRetur nMethod()
{
document.getEle mentById('modal return2').value = ModalDialog.val ue;
ModalDialogRemo veWatch();
}
</script>
<script runat="server">
sub page_load(s as object, e as eventArgs)
if not isPostBack then
Button1.Attribu tes.Add("onclic k", "YesNoCancel('Y es, no, or cancel
me','YesNoCance lReturnMethod() ');")
end if
end sub
</script>
<BODY >
<table border=1 cellpadding=2 cellspacing=2 align=center width="60%">
<tr><td align=left></td></tr>
<tr><td align=left></td></tr>
<tr><td align=left></td></tr>
<tr>
<td align=left><a href="javascrip t:YesNoCancel(' Yes, no, or cancel
me','YesNoCance lReturnMethod() ');">Show Modal #1</a>
1. <input type=text id=modalreturn1 name=modalretur n1
value=''></td>
</tr>
<tr>
<td align=left><a href="javascrip t:YesNoMaybe('Y es, no, or maybe
me','YesNoMaybe ReturnMethod()' );">Show Modal #2</a>
2. <input type=text id=modalreturn2 name=modalretur n2
value=''></td>
</tr>
<tr>
<td>
<BUTTON onclick="javasc ript:YesNoMaybe ('Yes, no, or maybe
me','YesNoMaybe ReturnMethod()' );" type="button">O pen Child Window</BUTTON>
</td>
</tr>
</table>
<form runat="server">
<asp:Button ID="Button1" text="submit" runat="server"/>
</form>
</BODY>
</HTML>
*************** *************** *************** *************** *************** *********
Thanks,
Tom
asp.net problem or a javascript problem.
I have a page that was originally created from a program I found on the net
that works well as an html page.
It brings up a modal popup window that I have been trying to work out for
days now and this was the closest I have been able to come.
I added a little asp.net code and an asp.net button and cannot get it to
work with that button. It seems to break the javascript code.
The page works fine with or without the asp.net code (as long as the asp.net
button is not pushed).
This works fine (as before) until I press the asp.net button. I am opening
alert boxes in various locations that all fire until the asp.net button is
pushed. From that time, all links and buttons will bring up the alert box
in the first javascript funtion, but the ModalDialogShow never gets called
or it just ignores it and therefore the popup window never gets called.
Why would the asp.net button cause the Javascript to quit functioning?
Why does the popup window not close when the buttons or links are pressed on
them?
*************** *************** *************** *************** *************** ***********
<%@ Page Language="VB" trace="false" debug="true" AutoEventWireup ="true"
ContentType="te xt/html" ResponseEncodin g="iso-8859-1" %>
<html>
<script language=JavaSc ript>
var ModalDialogWind ow;
var ModalDialogInte rval;
var ModalDialog = new Object;
ModalDialog.val ue = '';
ModalDialog.eve nthandler = '';
function ModalDialogMain tainFocus()
{
try
{
if (ModalDialogWin dow.closed)
{
alert("at ModalDialogWind ow.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,BodyText ,Buttons,EventH andler)
{
alert("inside ModalDialogShow ");
ModalDialogRemo veWatch();
ModalDialog.eve nthandler = EventHandler;
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('<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(Bod yText,EventHand ler)
{
alert("inside YesNoCancel")
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> ';
Buttons = '<BUTTON onclick="javasc ript:CloseForm( \'Yes\');"
type="button">Y es</BUTTON> ';
Buttons += '<BUTTON onclick="javasc ript:CloseForm( \'No\');" type =
"button">No </BUTTON> ';
Buttons += '<BUTTON onclick="javasc ript:CloseForm( \'Cancel\');" type =
"button">Cancel </BUTTON> ';
ModalDialogShow ("Dialog",BodyT ext,Buttons,Eve ntHandler);
}
function YesNoMaybe(Body Text,EventHandl er)
{
var Buttons='';
Buttons = '<a href=javascript :CloseForm("Yes ");>Yes</a> ';
Buttons += '<a href=javascript :CloseForm("No" );>No</a> ';
Buttons += '<a href=javascript :CloseForm("May be");>Maybe</a> ';
ModalDialogShow ("Dialog",BodyT ext,Buttons,Eve ntHandler);
}
function YesNoCancelRetu rnMethod()
{
alert("inside YesNoCancelRetu rnMethod");
document.getEle mentById('modal return1').value = ModalDialog.val ue;
ModalDialogRemo veWatch();
}
function YesNoMaybeRetur nMethod()
{
document.getEle mentById('modal return2').value = ModalDialog.val ue;
ModalDialogRemo veWatch();
}
</script>
<script runat="server">
sub page_load(s as object, e as eventArgs)
if not isPostBack then
Button1.Attribu tes.Add("onclic k", "YesNoCancel('Y es, no, or cancel
me','YesNoCance lReturnMethod() ');")
end if
end sub
</script>
<BODY >
<table border=1 cellpadding=2 cellspacing=2 align=center width="60%">
<tr><td align=left></td></tr>
<tr><td align=left></td></tr>
<tr><td align=left></td></tr>
<tr>
<td align=left><a href="javascrip t:YesNoCancel(' Yes, no, or cancel
me','YesNoCance lReturnMethod() ');">Show Modal #1</a>
1. <input type=text id=modalreturn1 name=modalretur n1
value=''></td>
</tr>
<tr>
<td align=left><a href="javascrip t:YesNoMaybe('Y es, no, or maybe
me','YesNoMaybe ReturnMethod()' );">Show Modal #2</a>
2. <input type=text id=modalreturn2 name=modalretur n2
value=''></td>
</tr>
<tr>
<td>
<BUTTON onclick="javasc ript:YesNoMaybe ('Yes, no, or maybe
me','YesNoMaybe ReturnMethod()' );" type="button">O pen Child Window</BUTTON>
</td>
</tr>
</table>
<form runat="server">
<asp:Button ID="Button1" text="submit" runat="server"/>
</form>
</BODY>
</HTML>
*************** *************** *************** *************** *************** *********
Thanks,
Tom
Comment