472,811 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 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 6568
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: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.