473,748 Members | 2,617 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="javas cript">
function doSearch() {
result=showModa lDialog("search mni.aspx?lastna me=smith");
alert(result);
}

</script>
<input id="btnOpenSear ch" onclick="doSear ch();" 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
hyperlinkcolumn s argument:

<asp:HyperLinkC olumn DataNavigateUrl Field="mniMiddl eName"
DataNavigateUrl FormatString="J avascript:testl ink();"
DataTextField=" mniMiddleName" HeaderText="Mid dle Name"
DataTextFormatS tring="{0}"></asp:HyperLinkCo lumn>

the javascript is simple:

function testlink(){
window.returnVa lue="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:

DataNavigateUrl FormatString="J avascript: var x=testlink();"
DataNavigateUrl FormatString="J avascript: 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 4305
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.showmoda ldialog
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"jm" <jo************ *@yahoo.com> wrote in message
news:c6******** *************** ***@posting.goo gle.com...
I have a parent window:
<script language="javas cript">
function doSearch() {
result=showModa lDialog("search mni.aspx?lastna me=smith");
alert(result);
}

</script>
<input id="btnOpenSear ch" onclick="doSear ch();" 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
hyperlinkcolumn s argument:

<asp:HyperLinkC olumn DataNavigateUrl Field="mniMiddl eName"
DataNavigateUrl FormatString="J avascript:testl ink();"
DataTextField=" mniMiddleName" HeaderText="Mid dle Name"
DataTextFormatS tring="{0}"></asp:HyperLinkCo lumn>

the javascript is simple:

function testlink(){
window.returnVa lue="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:

DataNavigateUrl FormatString="J avascript: var x=testlink();"
DataNavigateUrl FormatString="J avascript: 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.goo gle.com...
I have a parent window:
<script language="javas cript">
function doSearch() {
result=showModa lDialog("search mni.aspx?lastna me=smith");
alert(result);
}

</script>
<input id="btnOpenSear ch" onclick="doSear ch();" 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
hyperlinkcolumn s argument:

<asp:HyperLinkC olumn DataNavigateUrl Field="mniMiddl eName"
DataNavigateUrl FormatString="J avascript:testl ink();"
DataTextField=" mniMiddleName" HeaderText="Mid dle Name"
DataTextFormatS tring="{0}"></asp:HyperLinkCo lumn>

the javascript is simple:

function testlink(){
window.returnVa lue="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:

DataNavigateUrl FormatString="J avascript: var x=testlink();"
DataNavigateUrl FormatString="J avascript: 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
7162
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 applications window (while one of the (modal) dialogs is currently showing). When my applications window reappears again the dialog is no longer showing. I have to iconify the other applications window in order to make the dialog reappear again. What do...
0
1845
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 another window to display a report. To do this, I use the values of Sessions I initialize at the windows that called the modal dialog box. However, I noticed that the values of my Sessions were gone when I opened the modal dialog window ONLY when...
14
5484
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 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
5
3870
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 modal to my main window- even though I don't see how it could even be getting a reference to my main window. What I need is to open a new window but still have my main window available for interaction- the way it opens now it forces focus on this...
2
7086
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 dialog window? 2. The dialog window in question was, in turn, created from a dialog window. I need to post data back to that one too (that which the user selected in the top-most dialog window). How do I send data back to this window?
4
3113
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 one then click on an add button it adds the item to a list box, but when you click on add (this is in a modal dialog box) it opens the postback in a new window outside of the modal dialog box, how do you force it to postback to the modal dialog?...
10
2755
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 preview DIV) 2. when users close the dialog, the application receives the URL to the selected graphic. 3. the modal dialog lets the users upload a new graphic if the dialog does not present them with one they are already happy with. 4. upon uploading...
9
4921
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 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. ****************************************************************************
3
1396
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 directly from html script, but instead of redirecting the current dialog, a whole new window always pops up. Does anyone have a way to actually redirect the modal dialog without it being in a separate window?
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9386
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4608
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.