• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1124
  • Last Modified:

returnValue is null after calling window.ShowModalDialog(....)

I have an Asp.net project. One aspx page displays another as a modal dialog box. The return value is being passed back as "null" and I don't know why? Also alert(returnValue); will display the value as null. Can someone help me figure out why? Attached is the zip file for the project. Or the code markup and CS is included inline below.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_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">

<script language="javascript" type="text/javascript">
function ShowPopup()
{
    var returnValue = window.showModalDialog('ModalPopup.aspx', 'dialogHeight:100px;dialogWidth:280px;status:no');
    alert(returnValue);
}
</script>
<title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:Button ID="Button1" runat="server" Text="Show Popup"
            OnClientClick="javascript:ShowPopup()" />  
    </div>

    </form>
</body>
</html>

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

-----------------------------------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModalPopup.aspx.cs" Inherits="ModalPopup" %>

<!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">
<base target=_self>
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
        Text="Close Popup" />
    </form>
</body>
</html>

=====================C# code for ModalPopup.aspx
/* Modal Popup.aspx */
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ModalPopup : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write("<script language='javascript'> {window.ReturnValue='hello';self.close();}</script>");
    }
}
0
brgdotnet
Asked:
brgdotnet
1 Solution
 
krishna kishore mellacheruvu venkataCommented:
is modelpopup.aspx is in the same folder as the asp.net page. other wise it gives error.
0
 
Robert SchuttSoftware EngineerCommented:
javascript is case-sensitive, in the modalpopup.aspx code, use:
window.returnValue

Open in new window

(you have capital R in returnValue at the moment)
0
 
brgdotnetAuthor Commented:
Thank you. I could just slap myself for that one.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now