473,721 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modal Window Posting Back to Itself

1 New Member
I've seen many posts discussing the options we have when using modal windows within a web based application. Often times it seems the greatest hurdle is simply getting the modal window to post back to itself. It appears that most of these threads where this was discussed have been archived, so I'm bringing this topic up again to offer a couple suggestions on this topic.

I noticed that most people use the concept of posting to an iFrame. I used to do this with some degree of success, but you wind up with a bunch of extra pages in your app - 1 to be the modal window with just an iFrame on it and the other page to be the form post target which handles data changes, etc.

My suggestion would be to create a script that runs each time the page is opened as a modal window which would assign a name to itself (the current window).
Expand|Select|Wrap|Line Numbers
  1. ...
  2. </head>
  3. <body>
  5. <script language=javascript type="text/javascript">
  6.     window.name = "MyModalPopup";
  7. </script>
  8.     <form ...
Then within the form declaration, you can specify the named window to submit to:

Expand|Select|Wrap|Line Numbers
  1. ...
  2. <form id="form1" runat="server"  target="MyModalPopup">
  3. ...
It is the most elegant solution I have found so far. Also, most modal popups have some sort of Save/Cancel buttons on them. I have had great success by using the following code to get these to work. My example shows it in the ASP.NET context, but it can easily adapt to classic asp without the server roundtrip.

Handle the Cancel routine:

Expand|Select|Wrap|Line Numbers
  1. Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
  2.         Response.Write("<SCRIPT language=javascript>window.close();</SCRIPT>")
  3.     End Sub
Handle the Save routine:

Expand|Select|Wrap|Line Numbers
  1. Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
  2.         'example call to a function returning boolean value
  3.         If UpdateDB() Then
  4.             'this is line below is optional depending on if you want to close
  5.             'the window automatically or not.
  6.             Response.Write("<SCRIPT language=javascript>window.close();</SCRIPT>")
  7.         Else
  8.             'write some sort of error message or js alert to the page notifying 
  9.             'the user of the updatedb error
  10.         End If
  12.     End Sub
I've always gotten great ideas from anonymously browsing this forum...I hope this contribution can help someone out there!
Feb 21 '07 #1
0 1800

Sign in to post your reply or Sign up for a free account.

Similar topics

by: martin de vroom | last post by:
Hi, I have a web page that opens a modal dialog (client side) in the following manner onclick="window.showModalDialog('/dialog.asp',null,'dialogHeight: 200px; dialogWidth: 400px; dialogTop: 300px; dialogLeft: 150px; edge: Sunken; center: Yes; help: No; resizable: No; status: No;');"> and the page loads in the modal dialog no problem.
by: Lee | last post by:
I am using a modal window and an iFrame to try and pull a return value back. I am doing this across domains. I have the value returned from the modal window to the iFrame window but I can not get the value returned to the parent window. The alert in the parent window always returns undefined errors. Any help would be much appreciated. I call the modal window and wait for the return as such: function LCC()
by: amith | last post by:
Hi, I have a javascript, calendar.js which i use to enable my client to select the date. This calendar pops up on the click of a gif image. But the problem is that this poped up window is not modal in nature(i do not want the user to go the parent page unless he selects some date in the calendar popup). In the javascript calendar.js he has used window.open() function to pop up the window. i just want to know whether we have any...
by: Russell | last post by:
I have a quirky issue that I believe involves timing and only 2 hairs left to pull. I have a modal dialog that is an IFrame. The IFrame contains another window - which contains the appropriate title. I am trying to change the title of the IFrame window to be that of the contained window title. If I uncomment the alert statement below - the title change works. Comment out the alert - and - no title change.
by: Andrew Baker | last post by:
OK this has me perplexed, puzzled and bamboozled! I have a remoting service which I displayed a message box in. I then wondered what would happen if a client made a call to the service while the message box was being displayed. Since the call comes in on a different thread the client call was not blocked. This seemed to make sense to me. Next I thought, what will happen when the client calls into the server if I try to use a delegate...
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?
by: Earl Teigrob | last post by:
Can a Modal Dialog Box do forms ASP.NET forms validation from within the Modal Box? I want to pop up a dialog box to the user and have it do its own post backs with validation checking and then save the data and close the dialog when the page is valid. I have read a little about using Iframes to post back to, but was wondering if this would work for what I am trying to do? Also, does anyone have a code sample of this (postback from modal...
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...
by: Mike | last post by:
Hi, I'm having a problem with modal forms on windows. I've written a very short test program, with a main window and a form called from the main window. The form is set to modal with form.setModal(1) before calling form.show(). All works as expected on Linux. The form is modal, not allowing the main window to received the focus. If I call the form from within itself, the topmost form is modal, and not of the previous forms will...
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,...
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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,...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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...
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.