954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ModalDialog opens a new window on submit

Hello,

I am writing an ASP.NET application using javascript.
It uses a modal dialog which has a button.
When pressing the button another window is opened.
I'd like to perform the action on submit without opening a new window.
Here is some code for example:

code for first.aspx:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">
        function openModal() 
        {
            var returnValue = window.showModalDialog('modal.aspx', 'win','help:no;status:no;scroll:no;resize:no;dialogHeight:198px;dialogWidth:450px');
        } 
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <button id="btn" onclick="javascript:openModal()">Open</button>
    </div>
    </form>
</body>
</html>


code for modal.aspx:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="btn" runat="server" Text="click" onclick="btn_Click" />
    </div>
    </form>
</body>
</html>


code for modal.aspx.cs:

protected void btn_Click(object sender, EventArgs e)
        {
            Response.Write(DateTime.Now.ToString());
        }

How can I prevent the extra window from opening?

Thanks

danale
Newbie Poster
3 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 
GIREESH D A
Newbie Poster
1 post since Apr 2010
Reputation Points: 10
Solved Threads: 0
 
saulat78
Newbie Poster
1 post since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: