473,395 Members | 1,554 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,395 software developers and data experts.

Modal dialog windows position on postback

Rod
I have an asp.net application where some of the interaction with the
user is through modal dialog windows. This works very well except for
the annoying fact that the dialog window always returns to its initial
position when the user posts back (by clicking a button, etc.)

I have all of the fundamentals for asp.net modal dialogs in place, such
as using <base target="_self"> in the header...

To reiterate the problem for the sake of clarity: The users would like
to be able to reposition the modal dialogs and have the dialog maintain
its position when a postback is caused via clicking a button, etc.
Instead the modal dialog always returns to the position where it was
initally created.

What technique can I use to have the modal dialg remember its position
on postback.

This is an important issue for my client. I will post to this
newsgroup the solution I find (whether by assistance from
comp.lang.javascript, etc. -- or by my research).

Thanks,
Rod

Jul 23 '05 #1
3 6612
Rod
I have found a 90% solution for how to get a modal dialog to maintain
its position after postback. (More later on the remaining 10%.)

In a nutshell, when the user clicks a button or other control that
causes a postback/submit, I retain the window.screenLeft and .screenTop
in hidden text inputs, and include script to set the window.dialogLeft
and .dialogTop in the response.

This is not a 100% solution. The dialog maintains its postion, but if
you move the dialog and then do a submit/postback, it will jump back to
its original (prior to moving the dialog) position for a brief moment
until the positioning script is run to place it to where you moved it.
I haven't figured out how to overcome that, so I appreciate any
suggestions or ideas.

Now for more details. First of all, this is an ASP.Net appliction with
VB.Net as the server-side codebehind langauge. In the dialog, I have
two hidden <aspnet:textbox runat="server"> controls whose IDs are
hidXPos and hidYPos, respectively.

I have a javascript function whose purpose is to retain the current
window position. It is placed in the onclick event handler for any
control that does a submit/postback -- prior, of course, to doing the
submit.

function RecordPosition() {
var ohidXPos = document.getElementById('hidXPos');
var ohidYPos = document.getElementById('hidYPos');

ohidXPos.value = window.screenLeft;
ohidYPos.value = window.screenTop;
}
In the server-side code-behind, the Page_Load sub, which handles the
Page Load event, contains the following code snippit. Notice that I
subtract 3 pixels from dialogLeft and 22px from dialogTop to compensate
for thw window border and caption bar.
If hidXPos.Text <> "" And hidYPos.Text <> "" Then
Dim strScr As New System.Text.StringBuilder
strScr.Append("<script language='javascript'>" & vbNewLine)
strScr.Append("window.dialogLeft = '")
strScr.Append(hidXPos.Text - 3)
strScr.Append("';" & vbNewLine)
strScr.Append("window.dialogTop = '")
strScr.Append(hidYPos.Text - 22)
strScr.Append("';" & vbNewLine)
strScr.Append("</script>" & vbNewLine)
RegisterStartupScript("position", strScr.ToString)
End If
This produces script that looks like the following, for example:

<script language='javascript'>
window.dialogLeft = '259';
window.dialogTop = '117';
</script>
Another idea I tried unsuccessfully was to set window.dialogLeft and
Top in the above RecordPosition function. That seemed to have no
effect.

Thanks,
Rod

Jul 23 '05 #2
In article <11**********************@g14g2000cwa.googlegroups .com>,
RE****@jswcoinc.com enlightened us with...

To reiterate the problem for the sake of clarity: The users would like
to be able to reposition the modal dialogs and have the dialog maintain
its position when a postback is caused via clicking a button, etc.
Instead the modal dialog always returns to the position where it was
initally created.

What technique can I use to have the modal dialg remember its position
on postback.


Is this postback occuring in the parent window or the modal dialog?

--
--
~kaeli~
If the funeral procession is at night, do folks drive with
their lights off?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3
Rod
The postback is occuring in the modal dialog.

Jul 23 '05 #4

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

Similar topics

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...
4
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...
2
by: A Traveler | last post by:
Hello all, Here is my situation... i have a page which has a dropdown of companies. Next to it i have a "New" button for creating a new company. What i would like to do is to show a modal dialog...
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...
1
by: John | last post by:
Hi all, I have a situation where I'm using a modal dialog to merely show the user some data. Once the user has finished, there is only one button to click to return to the previous (parent) page...
2
by: sthrudel | last post by:
Hi! I'm working on a web application in Asp.net and what I would like to have is a cross borwser modal dialog which accepts user's input. I would like to catch what the user clicked on the...
10
by: bern11 | last post by:
If Form1 opens Form2 modally, how do I capture clicks on Form1 when Form2 is open? I want to click on Form1 and read the mouse co-ordinates into Form2. Since Form2 is open modally, Form1...
11
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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...

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.