我有个页面放入了Gridview,对Gridview写了CommandRow的方法如下:    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string cmd = e.CommandName;
        int num = Convert.ToInt32(e.CommandArgument);
        if (cmd == "ShowMessage")
        {            Response.Write("<script   language='JavaScript'>  window.open('Default.aspx?messageId='+num,'newwindow','height=500,width=500,top=200,left=500,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no,depended=no' )</script>");
            
        }
    }
我想实现将num这个值传到页面Default.aspx,请各位看官帮我看看我的这个JS脚本应该如何改,在线等,谢谢

解决方案 »

  1.   


    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 
        { 
            string cmd = e.CommandName; 
            int num = Convert.ToInt32(e.CommandArgument); 
            if (cmd == "ShowMessage") 
            {             Response.Write(" <script  language='JavaScript'>  window.open('Default.aspx?messageId=num','newwindow','height=500,width=500,top=200,left=500,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no,depended=no' ) </script>"); 
                
            } 
        } 
    'Default.aspx?messageId=num'
    就这么写。
      

  2.   

    Response.Write(" <script  language=\"JavaScript\">  window.open(\"Default.aspx?messageId="+num+",\"newwindow\",\"height=500,width=500,top=200,left=500,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no,depended=no\" ) </script>"); 
      

  3.   

    protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
               
                GridView1.Rows[i].Cells[0].Text = "<a href='Frzhipiao.aspx?id=" + GridView1.DataKeys[i].Value.ToString() + "&name=" + TextBox2.Text + "'>" + GridView1.Rows[i].Cells[0].Text + "</a>";        }
        }照着改
      

  4.   

    不行啊周公,我试了,这样写不在我放GridView页面弹出DefaulT页面
      

  5.   

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 
        { 
            string cmd = e.CommandName; 
            int num = Convert.ToInt32(e.CommandArgument); 
            if (cmd == "ShowMessage") 
            { 
             this.ViewState["num"]=num ;
             Page.RegisterStartupScript("myscript", "<script>msg()</script>");
            
                
            } 
        } 
    <script language ="javascript" >

         function msg()
    {
    window.open('Default.aspx?messageId='+this.ViewState["num"],"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=750,height=450,left=200,top=10");
    }
    </script>试试...
      

  6.   

    你使用摸板列,绑定时直接生成js脚本,根本就不再需要服务器来干预了....而且可以把js写成一个函数,只需要传递id就可以了介绍代码function ShowMessage(id)
    {
    window.open('Default.aspx?messageId='+id,'newwindow','height=500,width=500,top=200,left=500,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no,depended=no');
    }<a href='#' onclick='ShowMessage(<%#DataBinder.Eval(Container.DataItem,"ID")%>)'>ShowMessage</a>
      

  7.   

    周公,你的第二中方法能传,可跟我需求不符啊。我要在父页面上弹出Default页面,父页面保留,Default页面什么工具栏啊什么的都没有我才用的window.open这个方法的,可还想传值就不知道怎么改了,还望指教
      

  8.   

    SHowBO你的方法我试了JScript code这个的不行啊,我的Default页面我弹不出来,你说的直接绑方法,我不能用啊,因为我只想点击后在父页面弹出个什么导航条都没有的窗口所以不能直接绑定超连接的方法,就直接用我的JS脚本传num应该怎么写啊,望各位指教 
      

  9.   

    或者
     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 
        { 
            string cmd = e.CommandName; 
            int num = Convert.ToInt32(e.CommandArgument); 
            if (cmd == "ShowMessage") 
            { 
    //=========
                Response.Write(" <script  language='JavaScript'>  window.open('Default.aspx?messageId='+"+num+",'newwindow','height=500,width=500,top=200,left=500,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no,depended=no' ) </script>"); 
                
            } 
        } 
      

  10.   

    问下六楼的老师
            <script language ="javascript" >     function msg() 

    window.open('Default.aspx?messageId='+this.ViewState["num"],"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=750,height=450,left=200,top=10"); 

    </script> 
    这句写哪
      

  11.   

    html 页面中,直接复制就OK
      

  12.   

    SHOWBO老师的方法成功了,谢谢大家,我加分感谢所有参与帮助我的朋友