473,569 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript not working when part of asp.net page.

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="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',
'YesNoCancelRet urnMethod()');" )
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', 'modalreturn2',
'Yes, no, or cancel me', 'YesNoCancelRet urnMethod()');" >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=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;&nbsp;& nbsp;&nbsp; ';
Buttons += '<a
href=javascript :CloseForm("No" );>No</a>&nbsp;&nbsp;& nbsp;&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>&nbsp;</p>

</body>
</html>
*************** *************** *************** *************** **************

Thanks,

Tom
Nov 19 '05 #1
9 4896
I made some changes here to better see what was happening.

I added a button as well as buttons on one of the popup windows. I then
added an asp.net button and my asp.net 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
<snip>
Nov 19 '05 #2
You have a client side onclick event for the button. Are you sure there
isn't a javascript error that happens when you click the .NET button? And
you are not seeing it because script error notification is turned off?

I bet if you just had a button with no client side event handler for it, it
would be fine.

Just FYI, this has nothing to do with .NET. All javascript and HTML is dealt
with in the browser on the client. That ASP.NET button is just streamed out
as an <input>. You can look at the resulting HTML via View Source to see
what is being generated and what the problem could be.

"tshad" <ts**********@f tsolutions.com> wrote in message
news:u0******** ******@TK2MSFTN GP09.phx.gbl...
I made some changes here to better see what was happening.

I added a button as well as buttons on one of the popup windows. I then
added an asp.net button and my asp.net 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
<snip>

Nov 19 '05 #3
"Marina" <so*****@nospam .com> wrote in message
news:O2******** ******@TK2MSFTN GP15.phx.gbl...
You have a client side onclick event for the button. Are you sure there
isn't a javascript error that happens when you click the .NET button? And
you are not seeing it because script error notification is turned off?
How would I turn it on if it is off?

It does open the javascript window fine. It is just that when I press the
buttons in the popup window, nothing happens. I can close it by pushing the
window cancel (x). But at this point none of the buttons will work. Also,
but when I do press the buttons (from the parent window), I still get the
alert box from the YesNoCancelRetu rnMethod, which tells me that it is
calling the Javascript function.

Also, that is how you call a Javascript function (not sure why), but that is
how it is done.

I can call an alert or confirm button by:

myNextButton.At tributes.Add("o nclick", "return confirm('Are you sure you
want finish this test?');")

which works fine. Not sure why I don't have to have it as
"javascript:ret urn confirm('Are you sure you want finish this test?');"

I bet if you just had a button with no client side event handler for it,
it would be fine.
Right. Buttons are no problem. My problem is I need to attach a client
side pop up window for some reactions from the client. The normal
Javascript windows (alert, confirm) won't work as I need one of a couple of
answers from the client.

Just FYI, this has nothing to do with .NET. All javascript and HTML is
dealt with in the browser on the client. That ASP.NET button is just
streamed out as an <input>. You can look at the resulting HTML via View
Source to see what is being generated and what the problem could be.
Here is what is generated from asp.net:

*************** *************** *************** *************** *************** ***************
<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 name="_ctl0" method="post" action="popupTe st.aspx" id="_ctl0">

<input type="submit" name="Button1" value="submit" id="Button1"
onclick="YesNoC ancel('Yes, no, or cancel me','YesNoCance lReturnMethod() ');"
/>
</script></form>

*************** *************** *************** *************** *************** ***************

As you can see the input/Button1(asp.net ) onClick is similar to the html
Buttons onClick event (except that it doesn't have "javascript :" preceding
it. But even if I put that there, it still acts the same.

Thanks,

Tom
"tshad" <ts**********@f tsolutions.com> wrote in message
news:u0******** ******@TK2MSFTN GP09.phx.gbl...
I made some changes here to better see what was happening.

I added a button as well as buttons on one of the popup windows. I then
added an asp.net button and my asp.net 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
<snip>


Nov 19 '05 #4
Also, I added a couple of more alerts to see how far it is getting when
pressing the buttons on the popup form.

ModalDialogWind ow.document.wri te('function CloseForm(Respo nse) ');
ModalDialogWind ow.document.wri te('{ ');
ModalDialogWind ow.document.wri te(' alert("inside CloseForm"); ');
ModalDialogWind ow.document.wri te(' window.opener.M odalDialog.valu e =
Response; ');
ModalDialogWind ow.document.wri te(' alert("after setting ModalDialog.val ue
and before window.close"); ');
ModalDialogWind ow.document.wri te(' window.close(); ');
ModalDialogWind ow.document.wri te(' alert("after window.close"); ');
ModalDialogWind ow.document.wri te('} ');

It goes through all of them for all the other buttons (except that you have
to close the window directly, but the value does get transfered to the
textbox).

But for the asp.net button, it only gets to the first alert button and seems
to stop on the "window.opener. ModalDialog.val ue = Response" line where the
value is getting set. It never gets past that.

At that point the Javascript seems to be broken and never works for any of
the buttons (except that they do get to the first Javascript funtion).

Tom

"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
"Marina" <so*****@nospam .com> wrote in message
news:O2******** ******@TK2MSFTN GP15.phx.gbl...
You have a client side onclick event for the button. Are you sure there
isn't a javascript error that happens when you click the .NET button? And
you are not seeing it because script error notification is turned off?


How would I turn it on if it is off?

It does open the javascript window fine. It is just that when I press the
buttons in the popup window, nothing happens. I can close it by pushing
the window cancel (x). But at this point none of the buttons will work.
Also, but when I do press the buttons (from the parent window), I still
get the alert box from the YesNoCancelRetu rnMethod, which tells me that it
is calling the Javascript function.

Also, that is how you call a Javascript function (not sure why), but that
is how it is done.

I can call an alert or confirm button by:

myNextButton.At tributes.Add("o nclick", "return confirm('Are you sure you
want finish this test?');")

which works fine. Not sure why I don't have to have it as
"javascript:ret urn confirm('Are you sure you want finish this test?');"

I bet if you just had a button with no client side event handler for it,
it would be fine.


Right. Buttons are no problem. My problem is I need to attach a client
side pop up window for some reactions from the client. The normal
Javascript windows (alert, confirm) won't work as I need one of a couple
of answers from the client.

Just FYI, this has nothing to do with .NET. All javascript and HTML is
dealt with in the browser on the client. That ASP.NET button is just
streamed out as an <input>. You can look at the resulting HTML via View
Source to see what is being generated and what the problem could be.


Here is what is generated from asp.net:

*************** *************** *************** *************** *************** ***************
<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 name="_ctl0" method="post" action="popupTe st.aspx" id="_ctl0">

<input type="submit" name="Button1" value="submit" id="Button1"
onclick="YesNoC ancel('Yes, no, or cancel
me','YesNoCance lReturnMethod() ');" />
</script></form>

*************** *************** *************** *************** *************** ***************

As you can see the input/Button1(asp.net ) onClick is similar to the html
Buttons onClick event (except that it doesn't have "javascript :" preceding
it. But even if I put that there, it still acts the same.

Thanks,

Tom

"tshad" <ts**********@f tsolutions.com> wrote in message
news:u0******** ******@TK2MSFTN GP09.phx.gbl...
I made some changes here to better see what was happening.

I added a button as well as buttons on one of the popup windows. I then
added an asp.net button and my asp.net 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
<snip>



Nov 19 '05 #5
I think I know what is happening, but I don't know what to do about it.

I added the line:

ModalDialogWind ow.document.wri te(' if (window.opener &&
!window.opener. closed)alert ("window.ope ner still valid"); ');

to the code in the CloseForm function and it comes back as valid, but the
program may already doing it's postback and may have lost the object which
is on the page. And that is why it is lost. The object is gone.

I am not sure why the links get into the first function, but not to the
ModalDialogShow function. I can only assume it has something to do with the
Global object that is created at the start has now been replace with another
one (or is gone altogether) since there is no viewstate to save it.

I'd be curious if I am on the right path or not and if there is a way around
this problem.

Thanks,

Tom
"tshad" <ts**********@f tsolutions.com> wrote in message
news:Oo******** ******@TK2MSFTN GP10.phx.gbl...
Also, I added a couple of more alerts to see how far it is getting when
pressing the buttons on the popup form.

ModalDialogWind ow.document.wri te('function CloseForm(Respo nse) ');
ModalDialogWind ow.document.wri te('{ ');
ModalDialogWind ow.document.wri te(' alert("inside CloseForm"); ');
ModalDialogWind ow.document.wri te(' window.opener.M odalDialog.valu e =
Response; ');
ModalDialogWind ow.document.wri te(' alert("after setting
ModalDialog.val ue and before window.close"); ');
ModalDialogWind ow.document.wri te(' window.close(); ');
ModalDialogWind ow.document.wri te(' alert("after window.close"); ');
ModalDialogWind ow.document.wri te('} ');

It goes through all of them for all the other buttons (except that you
have to close the window directly, but the value does get transfered to
the textbox).

But for the asp.net button, it only gets to the first alert button and
seems to stop on the "window.opener. ModalDialog.val ue = Response" line
where the value is getting set. It never gets past that.

At that point the Javascript seems to be broken and never works for any of
the buttons (except that they do get to the first Javascript funtion).

Tom

"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
"Marina" <so*****@nospam .com> wrote in message
news:O2******** ******@TK2MSFTN GP15.phx.gbl...
You have a client side onclick event for the button. Are you sure there
isn't a javascript error that happens when you click the .NET button?
And you are not seeing it because script error notification is turned
off?


How would I turn it on if it is off?

It does open the javascript window fine. It is just that when I press
the buttons in the popup window, nothing happens. I can close it by
pushing the window cancel (x). But at this point none of the buttons
will work. Also, but when I do press the buttons (from the parent
window), I still get the alert box from the YesNoCancelRetu rnMethod,
which tells me that it is calling the Javascript function.

Also, that is how you call a Javascript function (not sure why), but that
is how it is done.

I can call an alert or confirm button by:

myNextButton.At tributes.Add("o nclick", "return confirm('Are you sure
you want finish this test?');")

which works fine. Not sure why I don't have to have it as
"javascript:ret urn confirm('Are you sure you want finish this test?');"

I bet if you just had a button with no client side event handler for it,
it would be fine.


Right. Buttons are no problem. My problem is I need to attach a client
side pop up window for some reactions from the client. The normal
Javascript windows (alert, confirm) won't work as I need one of a couple
of answers from the client.

Just FYI, this has nothing to do with .NET. All javascript and HTML is
dealt with in the browser on the client. That ASP.NET button is just
streamed out as an <input>. You can look at the resulting HTML via View
Source to see what is being generated and what the problem could be.


Here is what is generated from asp.net:

*************** *************** *************** *************** *************** ***************
<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 name="_ctl0" method="post" action="popupTe st.aspx" id="_ctl0">

<input type="submit" name="Button1" value="submit" id="Button1"
onclick="YesNoC ancel('Yes, no, or cancel
me','YesNoCance lReturnMethod() ');" />
</script></form>

*************** *************** *************** *************** *************** ***************

As you can see the input/Button1(asp.net ) onClick is similar to the html
Buttons onClick event (except that it doesn't have "javascript :"
preceding it. But even if I put that there, it still acts the same.

Thanks,

Tom

"tshad" <ts**********@f tsolutions.com> wrote in message
news:u0******** ******@TK2MSFTN GP09.phx.gbl...
I made some changes here to better see what was happening.

I added a button as well as buttons on one of the popup windows. I
then added an asp.net button and my asp.net 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
<snip>



Nov 19 '05 #6
Tom why don't u try this approach at :-
http://www.aspnetpro.com/NewsletterA...10bm_l/asp2004
10bm_l.asp

Hope it helps
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #7
"Patrick Olurotimi Ige" <ig*@iprimus.co m.au> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Tom why don't u try this approach at :-
http://www.aspnetpro.com/NewsletterA...10bm_l/asp2004
10bm_l.asp
I tried that.

It only seems to work in IE.

I tried using MS example from their site:

<html>
<head>
<script language="VB" runat="server">
Sub Page_Load( sender as Object,e as EventArgs)

'Form the script that is to be registered at client side.
Dim scriptString as String = "<script language=JavaSc ript> function
DoClick() {"
scriptString += "myForm.show.va lue='Welcome to Microsoft .NET'}<"
scriptString += "/"
scriptString += "script>"

If(Not IsClientScriptB lockRegistered( "clientScript") )
RegisterClientS criptBlock("cli entScript", scriptString)
End If
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10" >
<form id="myForm" runat="server">
<input type="text" id="show" style="width=20 0">
<input type="button" value="ClickMe" onclick="DoClic k()">
</form>
</body>
</html>

I tried this in Mozilla and the button does nothing. IE works fine.

The problem with a lot of these solutions is that you spend days getting
them to work and then find that they won't work for all browsers or, as in
the case of the one I was trying to get to work, there is some gotcha that
you can't find a way around. This seems to work fine until I used it work a
..net object.

In this case, I thought it my popup box would work and now I have to go into
my boss and tell him it won't.

Thanks,

Tom
Hope it helps
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #8
I worked on this all night and finally got it working, but the problem is
that it only works if you connect the value to an html button where there is
no postback.

I am using the RegisterClientS criptBlock you suggested.

I found that if I set the onClick to an asp.net object (asp:button), I lose
any value I wrote to the page during postback. For example:

<asp:textbox id="test" text="something " runat="server" />

If I set this "test" to "Yes", it will get reset to "something" during
postback. It doesn't keep the change I set it to.

Tom

"tshad" <ts**********@f tsolutions.com> wrote in message
news:OR******** *****@TK2MSFTNG P12.phx.gbl...
"Patrick Olurotimi Ige" <ig*@iprimus.co m.au> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Tom why don't u try this approach at :-
http://www.aspnetpro.com/NewsletterA...10bm_l/asp2004
10bm_l.asp
I tried that.

It only seems to work in IE.

I tried using MS example from their site:

<html>
<head>
<script language="VB" runat="server">
Sub Page_Load( sender as Object,e as EventArgs)

'Form the script that is to be registered at client side.
Dim scriptString as String = "<script language=JavaSc ript>

function DoClick() {"
scriptString += "myForm.show.va lue='Welcome to Microsoft .NET'}<"
scriptString += "/"
scriptString += "script>"

If(Not IsClientScriptB lockRegistered( "clientScript") )
RegisterClientS criptBlock("cli entScript", scriptString)
End If
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10" >
<form id="myForm" runat="server">
<input type="text" id="show" style="width=20 0">
<input type="button" value="ClickMe" onclick="DoClic k()">
</form>
</body>
</html>

I tried this in Mozilla and the button does nothing. IE works fine.

The problem with a lot of these solutions is that you spend days getting
them to work and then find that they won't work for all browsers or, as in
the case of the one I was trying to get to work, there is some gotcha that
you can't find a way around. This seems to work fine until I used it work a .net object.

In this case, I thought it my popup box would work and now I have to go into my boss and tell him it won't.

Thanks,

Tom

Hope it helps
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 19 '05 #9
"tshad" <tf*@dslextreme .com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I worked on this all night and finally got it working, but the problem is
that it only works if you connect the value to an html button where there is no postback.

I am using the RegisterClientS criptBlock you suggested.

I found that if I set the onClick to an asp.net object (asp:button), I lose any value I wrote to the page during postback. For example:

<asp:textbox id="test" text="something " runat="server" />

If I set this "test" to "Yes", it will get reset to "something" during
postback. It doesn't keep the change I set it to.
I need to find some way to write the data to something that will not be
changed when it gets posted back.

I looked at somehow writing to a session variable from javascript - but
can't seem to find a way to do that.

I tried using an html input tag to store the variable ,but it gets reset on
postback.

Tom
Tom

"tshad" <ts**********@f tsolutions.com> wrote in message
news:OR******** *****@TK2MSFTNG P12.phx.gbl...
"Patrick Olurotimi Ige" <ig*@iprimus.co m.au> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Tom why don't u try this approach at :-
http://www.aspnetpro.com/NewsletterA...10bm_l/asp2004 10bm_l.asp
I tried that.

It only seems to work in IE.

I tried using MS example from their site:

<html>
<head>
<script language="VB" runat="server">
Sub Page_Load( sender as Object,e as EventArgs)

'Form the script that is to be registered at client side.
Dim scriptString as String = "<script language=JavaSc ript>

function
DoClick() {"
scriptString += "myForm.show.va lue='Welcome to Microsoft ..NET'}<" scriptString += "/"
scriptString += "script>"

If(Not IsClientScriptB lockRegistered( "clientScript") )
RegisterClientS criptBlock("cli entScript", scriptString)
End If
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10" >
<form id="myForm" runat="server">
<input type="text" id="show" style="width=20 0">
<input type="button" value="ClickMe" onclick="DoClic k()">
</form>
</body>
</html>

I tried this in Mozilla and the button does nothing. IE works fine.

The problem with a lot of these solutions is that you spend days getting
them to work and then find that they won't work for all browsers or, as in the case of the one I was trying to get to work, there is some gotcha that you can't find a way around. This seems to work fine until I used it

work a
.net object.

In this case, I thought it my popup box would work and now I have to go

into
my boss and tell him it won't.

Thanks,

Tom

Hope it helps
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

136
9251
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.