473,418 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Modal Window Posting Back to Itself

1
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>
  4.  
  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
  4.  
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
  11.  
  12.     End Sub
  13.  
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 1791

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

Similar topics

2
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:...
5
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...
1
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...
3
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...
3
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...
2
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...
3
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...
10
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...
2
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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,...
0
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...

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.