473,498 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why can't I execute Javascript in a modal dialog window?

jm
I have a parent window:
<script language="javascript">
function doSearch() {
result=showModalDialog("searchmni.aspx?lastname=sm ith");
alert(result);
}

</script>
<input id="btnOpenSearch" onclick="doSearch();" type="button"
value="search" runat="server" text="Button" />
<input type=textbox id="txtResponse" >

In my child window, the popup populates and then has a bound
hyperlinkcolumn. For testing sakes, I just put this for the
hyperlinkcolumns argument:

<asp:HyperLinkColumn DataNavigateUrlField="mniMiddleName"
DataNavigateUrlFormatString="javascript:testlink() ;"
DataTextField="mniMiddleName" HeaderText="Middle Name"
DataTextFormatString="{0}"></asp:HyperLinkColumn>

the javascript is simple:

function testlink(){
window.returnValue="test";
window.close();
}

What I found was that if I click the hyperlinkcolumn in the modal
dialog, the javascript opens another window. It does not simply
execute the javascript. If I run the modal dialog as a normal page, I
can get code to execute (of course it does nothing as it is not a
dialog at that point) - no errors. It is simply because it is inside
the modal. Any ideas how to make this code execute?

I have tried:

DataNavigateUrlFormatString="javascript: var x=testlink();"
DataNavigateUrlFormatString="javascript: var x=if(testlink();)"

all of them open another window with the call to the javascript in the
address bar.

What am I doing wrong? Thank you.
Nov 18 '05 #1
2 4289
it's due to the properties of the ModalDialog window.... it's not meant to
do that type of stuff from what I've been told. Goto a window.open instead
of a window.showmodaldialog
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"jm" <jo*************@yahoo.com> wrote in message
news:c6**************************@posting.google.c om...
I have a parent window:
<script language="javascript">
function doSearch() {
result=showModalDialog("searchmni.aspx?lastname=sm ith");
alert(result);
}

</script>
<input id="btnOpenSearch" onclick="doSearch();" type="button"
value="search" runat="server" text="Button" />
<input type=textbox id="txtResponse" >

In my child window, the popup populates and then has a bound
hyperlinkcolumn. For testing sakes, I just put this for the
hyperlinkcolumns argument:

<asp:HyperLinkColumn DataNavigateUrlField="mniMiddleName"
DataNavigateUrlFormatString="javascript:testlink() ;"
DataTextField="mniMiddleName" HeaderText="Middle Name"
DataTextFormatString="{0}"></asp:HyperLinkColumn>

the javascript is simple:

function testlink(){
window.returnValue="test";
window.close();
}

What I found was that if I click the hyperlinkcolumn in the modal
dialog, the javascript opens another window. It does not simply
execute the javascript. If I run the modal dialog as a normal page, I
can get code to execute (of course it does nothing as it is not a
dialog at that point) - no errors. It is simply because it is inside
the modal. Any ideas how to make this code execute?

I have tried:

DataNavigateUrlFormatString="javascript: var x=testlink();"
DataNavigateUrlFormatString="javascript: var x=if(testlink();)"

all of them open another window with the call to the javascript in the
address bar.

What am I doing wrong? Thank you.

Nov 18 '05 #2
Set smartNavigatoin=true on the dialog page. Then the page should refresh
into itself.

Cathie

"jm" <jo*************@yahoo.com> wrote in message
news:c6**************************@posting.google.c om...
I have a parent window:
<script language="javascript">
function doSearch() {
result=showModalDialog("searchmni.aspx?lastname=sm ith");
alert(result);
}

</script>
<input id="btnOpenSearch" onclick="doSearch();" type="button"
value="search" runat="server" text="Button" />
<input type=textbox id="txtResponse" >

In my child window, the popup populates and then has a bound
hyperlinkcolumn. For testing sakes, I just put this for the
hyperlinkcolumns argument:

<asp:HyperLinkColumn DataNavigateUrlField="mniMiddleName"
DataNavigateUrlFormatString="javascript:testlink() ;"
DataTextField="mniMiddleName" HeaderText="Middle Name"
DataTextFormatString="{0}"></asp:HyperLinkColumn>

the javascript is simple:

function testlink(){
window.returnValue="test";
window.close();
}

What I found was that if I click the hyperlinkcolumn in the modal
dialog, the javascript opens another window. It does not simply
execute the javascript. If I run the modal dialog as a normal page, I
can get code to execute (of course it does nothing as it is not a
dialog at that point) - no errors. It is simply because it is inside
the modal. Any ideas how to make this code execute?

I have tried:

DataNavigateUrlFormatString="javascript: var x=testlink();"
DataNavigateUrlFormatString="javascript: var x=if(testlink();)"

all of them open another window with the call to the javascript in the
address bar.

What am I doing wrong? Thank you.

Nov 18 '05 #3

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

Similar topics

2
7136
by: Bjoern Obermeyer | last post by:
Hi, I am writing an application with a JFrame as the main window and several dialogs to gain user input. The problem arises when another window (from a differnent apllication) hides my...
0
1815
by: Nonoy of Philippines | last post by:
Hello, guys... I'm just starting to develop web applications and I have this problem regarding Session objects At some parts of my application, I open modal dialog window which also opens...
14
5419
by: tshad | last post by:
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...
5
3851
by: MrNobody | last post by:
I am using the no-arg ShowDialog() method hoping that the window would not be modal to any other window like the other ShowDialog(IWin32Window) method does, but when this opens it somehow becomes...
2
7070
by: John | last post by:
Hi all, I have a modal dialog window from which a user selects a few rows from a datagrid and then clicks on an image button. My question is two-fold: 1. How do I post data back to the same...
4
3094
by: Brian Henry | last post by:
Hi, is there a way to get a form to post back to a modal dialog box when it was posted from a modal dialog to start with? here is the problem... I have a form with combo boxes and when you select...
10
2731
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a...
9
4885
by: tshad | last post by:
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...
3
1382
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I open a window with showModalDialog. From within this modal dialog I want to redirect the dialog to another URL. I have tried all kinds of methods to redirect the page from the server and...
0
7126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7168
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,...
0
7210
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...
0
7381
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4595
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...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
293
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...

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.