想实现的功能是:在a.aspx中通过模态对话框传递参数history到b.aspx中,在b.aspx中获取history参数,并给后台函数进行调用,组合成sql语句,绑定到listbox中。现在,在后台page_load页面中txtHistory.Text的值始终为空,不知道哪里出问题了,请大家帮帮忙,谢谢。
主页面a.aspx中js:
var history;
function doModal(his)
{
     var cSearchValue = window.showModalDialog("b.aspx",history,"dialogWidth:400px; dialogHeight:500px; resizable:yes; status:no; scroll:yes; help:no; center:yes;");
}b.aspx中的js:
function getArguments()
{
    obj = window.dialogArguments;  //obj中填充查询条件信息
    document.getElementById ("txtHistory").value = obj;        
}b.aspx中的html:
  <div style ="display :none">
     <asp:TextBox ID = "txtHistory" runat="server" Visible = "true"></asp:TextBox>
  </div>b.aspx.cs page_Load()
{
 Page.ClientScript.RegisterStartupScript(this.GetType(), "getArguments", "getArguments();", true);
     String history = txtHistory.Text.ToString();
}

解决方案 »

  1.   

    1. 传的参数history是字符还是对象,var history = new Object(); history.pro = "xxx";
    2. 获取参数后,你可以先判断下obj是否有效
    3. 你的这个页面是否位于母版页、用户控件中?如果是 document.getElementById ("<%=txtHistory.ClientID%>").value
      

  2.   

    cSearchValue = showmodaldialog仅只接收window.returnValue吧,学浅,不清楚是不是能接收 Arguments。
      

  3.   

    window.showModalDialog 也只有IE才支持!!!页面间传值:
    1、url 重写
    2、 cookie
    3、 session
    4、 application
    5、 静态变量
      

  4.   

      window.opener.getElementById ("txtHistory").value = obj;   
      

  5.   

    history是一个字符串型变量。
    b.aspx的js函数中可以获取到history的值。我想在页面加载前获取这个值,然后给后台使用生成数据,然后再完成b.aspx页面的加载
      

  6.   

    cs文件是先执行的,js 后执行的,
    你可这样
    window.showModalDialog("b.aspx?data="+encodeURIComponent(history))
    b.aspx
    Page_LoadRequest.QueryString["data"]获得