I'm using forms authentication in my asp.net application and having
success with exception of one problem. On several pages I have
controls that execute client javascript to call
window.showModalDialog(). If forms authentication times out while one
of these pages is displayed and the user clicks on one of the buttons
that calls window.showModalDialog(), the popup executes but displays
the login page.
Somehow, I'd like to have the login page detect that it's been opened
within a popup/modal dialog, close that window and cause the main
window to open login.aspx.
Can anyone point me to an example?
thanks!
[MSFT] - 21 Oct 2004 06:30 GMT
Hello,
I suggest you may consider a webform button instead of the html button to
invoke the script, for example, add following two control on the page:
<asp:Literal id="Literal1" runat="server"
EnableViewState="False"></asp:Literal>
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 432px; POSITION:
absolute; TOP: 240px" runat="server"
Height="56px" Width="120px" Text="Button"></asp:Button>
And add following code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Literal1.Text = "<script
language=javascript>window.showModalDialog('webform2.aspx');</script>"
End Sub
As you see, when the button was clicked, the literal control's text will be
set a section of script to invoke showModalDialog. If the form
authentication is timeout, logon form will be shown in this IE window. No
dialog was displayed.
Hope this help,
Luke
(This posting is provided "AS IS" with no warranties, and confers no
rights.)
MarkMurphy - 21 Oct 2004 19:04 GMT
Using a literal with script entered at postback worked like a charm. I
never would have considered that route. Thanks!
I have the same issue I discovered with some server-side control
hyperlinks that have their target window set to new. I'll have to
figure out a similar trick on those but it's a little different since
there is no postback.
Again, I'm thinking of solutions such as I originaly mentioned, having
the opened login page examine itself to see if it was opened as a
modal dialog or new window.
[MSFT] - 22 Oct 2004 03:51 GMT
It may be very hard for a page to tell if it is opened in a new window or a
dialog. Actually, they are all IE window. We may check a window object's
opener and parent properties, this may help. However, consider we also need
to close current dialog window and inform the parent window to refresh if
timeout, this also cause many trouble. Therefore, I think the best way is
to detect in parent window for timeout.
Luke
MarkMurphy - 25 Oct 2004 21:56 GMT
Thanks Luke,
You recommend checking for the timeout in the parent window. By this
do you mean that rather than using asp:hyperlink I should use a
control that will cause a postback? In the other case I was using a
button, which would postback.
-Mark
[MSFT] - 26 Oct 2004 04:05 GMT
Yes, I think a serve side control in necessary here. You can consider a
button or a link button here.
Luke
[MSFT] - 28 Oct 2004 09:49 GMT
Any further questions? If so, please feel free to post here.
Luke
danyerex - 10 May 2005 23:06 GMT
Nothing is as fast as a quick hyperlink that opens up a dialog...
forcing users through a postback is painful.
If the popup page gets redirected to your login page, have the code
behind in the login page check the referring page to see if it's a
'popup' page (granted, you'll have to maintain this list), and if so,
adjust the login page to display a simple message: "Your session has
timed out. Please close this window and re-login to the application."
--
danyerex