返回值 
DialogPage.aspx: 
window.returnvalue="aaa"; ParentPage.aspx: 
var str=window.showModalDialog("DialogPage.aspx"); 
这种语句是不是要用Page.RegisterStartupScript或Page.RegisterClientScriptBlock方法来注册.
那么返回来的var如何赋值给我在ParentPage.aspx中定义的变量private string returnvalue;

解决方案 »

  1.   

    除非提交页面,不然的话,不会直接把var赋值给private string returnvalue;
      

  2.   

    你可以使用
    <script language="javascript">
    var str=window.showModalDialog("DialogPage.aspx");
    //把返回值赋值给页面中的TextBox1
    window.opener.document.getElementById("TextBox1").value = str;
    </script>
      

  3.   

    也可以在客户端设置一个隐藏的textbox或者什么,让它在服务器端也运行,这样,在客户端赋值,在服务器端也就可以控制了。
      

  4.   

    同意 swordragon(古道热肠)的方法.
    或者象 xiaohuluwa(葫芦娃) 说的,用以个hidden 设置成runat="server"
    <input type="hidden" id="strValue" value="aaa" runat="server">
    然后再.aspx.cs定义
    protected System.Web.UI.HtmlControls.HtmlInputHidden strValue;<script language="javascript">
    <!--
      var str = window.showModalDialog("DialogPage.aspx"); 
      document.getElementById('strValue') = str;
    -->
    </script>这样就可以在.aspx.cs中对strValue值造作了.