Hi, was wondering if someone can help me understand my page's behavior below. I have a main page called Default.aspx that uses showModalDialog to open a dialog window. When I close my dialog window I expect it to simply go back to my main page. But what
happens after the dialog closes is that another Dialog.aspx page is opened. Would someone help me understand why it's behaving this way? Thanks!
Use This code for model dialog box its work for me
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.19.custom.min.js" type="text/javascript"></script>
<script>
$(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-modal" ).dialog({
height: 140,
modal: true
});
});
</script>
<div class="demo">
<div id="dialog-modal" title="Basic modal dialog">
<p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
</div>
<!-- Sample page content to illustrate the layering of the dialog -->
<div class="hiddenInViewSource" style="padding:20px;">
<p>Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.</p>
<form>
<input value="text input" /><br />
<input type="checkbox" />checkbox<br />
<input type="radio" />radio<br />
<select>
<option>select</option>
</select><br /><br />
<textarea>textarea</textarea><br />
</form>
</div><!-- End sample page content -->
</div><!-- End demo -->
<div class="demo-description">
<p>A modal dialog prevents the user from interacting with the rest of the page until it is closed.</p>
</div><!-- End demo-description -->
jerrydy
Member
3 Points
21 Posts
Why showModalDialog opens a new page after dialog is closed
Aug 21, 2012 06:58 AM|LINK
Hi, was wondering if someone can help me understand my page's behavior below. I have a main page called Default.aspx that uses showModalDialog to open a dialog window. When I close my dialog window I expect it to simply go back to my main page. But what happens after the dialog closes is that another Dialog.aspx page is opened. Would someone help me understand why it's behaving this way? Thanks!
-- Default.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="ModalDialog._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/javascript">
function openDialog() {
var returnValue = window.showModalDialog("Dialog.aspx", window, "status: no; resizable: yes; scroll: no;");
alert("returnValue = " + returnValue);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:Button ID="Button1" runat="server" Text="Open Dialog" OnClientClick="openDialog();" />
</form>
</body>
</html>
-- Default.aspx.vb
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
-- Dialog.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Dialog.aspx.vb" Inherits="ModalDialog.Dialog" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/javascript">
window.onbeforeunload = doBeforeUnload;
function doBeforeUnload() {
alert("Dialog is closing");
}
function closeDialog() {
window.returnValue = 10;
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Close" OnClientClick="closeDialog();" />
</form>
</body>
</html>
-- Dialog.aspx.vb
Public Partial Class Dialog
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
SohailShaikh
Contributor
6281 Points
1188 Posts
Re: Why showModalDialog opens a new page after dialog is closed
Aug 21, 2012 07:07 AM|LINK
Use This code for model dialog box its work for me
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script> <script src="js/jquery-ui-1.8.19.custom.min.js" type="text/javascript"></script> <script> $(function() { $( "#dialog:ui-dialog" ).dialog( "destroy" ); $( "#dialog-modal" ).dialog({ height: 140, modal: true }); }); </script> <div class="demo"> <div id="dialog-modal" title="Basic modal dialog"> <p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p> </div> <!-- Sample page content to illustrate the layering of the dialog --> <div class="hiddenInViewSource" style="padding:20px;"> <p>Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.</p> <form> <input value="text input" /><br /> <input type="checkbox" />checkbox<br /> <input type="radio" />radio<br /> <select> <option>select</option> </select><br /><br /> <textarea>textarea</textarea><br /> </form> </div><!-- End sample page content --> </div><!-- End demo --> <div class="demo-description"> <p>A modal dialog prevents the user from interacting with the rest of the page until it is closed.</p> </div><!-- End demo-description -->Sohail Shaikh
raju dasa
Star
14746 Points
2499 Posts
Re: Why showModalDialog opens a new page after dialog is closed
Aug 21, 2012 07:11 AM|LINK
Hi,
Asp.net button controls may be the problem(they do postback).
remove asp.net buttons and use html buttons in place (in both the pages)
<input type="button" ID="Button1" value="Open Dialog" onclick="openDialog();" />
rajudasa.blogspot.com || blog@opera
Mahesh Darku...
Participant
896 Points
238 Posts
Re: Why showModalDialog opens a new page after dialog is closed
Aug 21, 2012 07:12 AM|LINK
simply use clientscripts to display popup box..
like
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('write message here');", true);
or if u want to open new aspx page as popup then write code like following
Response.Write("<script language='javascript'>{window.open('frmReportViewer.aspx');}</script>");
jerrydy
Member
3 Points
21 Posts
Re: Why showModalDialog opens a new page after dialog is closed
Aug 21, 2012 05:38 PM|LINK
completely forgot about the postback. it worked after I converted it into an html button as you suggested. thanks!