using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Admin : System.Web.UI.MasterPage
{
   
    {
        string where = "TestState = 0";
        ZCGLModel.f_Test_List list = ZCGLBLL.f_Test.Select_f_TestByTestState1(where);
        if (ZCGLBLL.f_Test.GetCount(where) > 0)
        {
            //Response.Redirect("f_MsgAlert.aspx?TestID=" + list[0].TestID + "", true);
           
            string strTestID = list[0].TestID.ToString().Trim();
            string strJS = "<script language='javascript' type='text/javascript'>";
            strJS += " fn_OpenMsgWindow('" + strTestID + "','_blank'); ";
            strJS += "</script>";
            Page.RegisterStartupScript("winOpenJS", strJS);
             
        }
    }
    
}我想做的是 弹出一个新页面 并传递参数  但是不能关闭当前页面 

解决方案 »

  1.   

     Page.RegisterStartupScript("winOpenJS", strJS);修改成这样试试
     Page.RegisterStartupScript(GetType(),"winOpenJS", strJS);
    你可以看看前台有没有这段代码
      

  2.   

    你把脚本改成alert(3)
    看看能弹出吗?能的话可能你的js函数不存在或调用错误。
      

  3.   

    是不是用到了updatepanel?如果是的话,要用ScriptManager.RegisterStartupScript。
      

  4.   

    用到了   <asp:UpdatePanel ID="UpdatePanel1" runat="server">    
                    <ContentTemplate>             
                       <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick" />       
                                <span id="clock"  runat="server"></span>          
                                  </ContentTemplate>      
                                    </asp:UpdatePanel>  protected void Timer1_Tick(object sender, EventArgs e)
        {
            string where = "TestState = 0";
            ZCGLModel.f_Test_List list = ZCGLBLL.f_Test.Select_f_TestByTestState1(where);
            if (ZCGLBLL.f_Test.GetCount(where) > 0)
            {
                string id = list[0].TestID;
                Response.Write("<script language='javascript'>");
                Response.Write("window.open('f_MsgAlert.aspx?TestID=" + id+ "','newwindow','height=600,width=600,top=200,left=200,toolbar=no,menubar=no,scrollbar=yes,resizable=no,location=no,status=no');");
                Response.Write("</script>");
                Response.End();
            }
        }
    这样不行吗
      

  5.   

    4楼都说了
    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.UpdatePanel1.GetType(), "", "这里填写你的脚本;", true);
      

  6.   

    因为使用了UpdatePanel
    导致你的js脚本没有使用,请使用
    ScriptManager.RegisterStartupScript方法。
      

  7.   

     page.ClientScript.RegisterStartupScript(page.GetType(), "ShowWindow", "<script type='text/javascript' >" +"fn_OpenMsgWindow('" + strTestID + "','_blank')" + "</script>");用这个试试
      

  8.   

    因为你这个页面继承的是System.Web.UI.MasterPage,试试继承System.Web.UI.Page
      

  9.   

    我想做的是 弹出一个新页面 并传递参数  但是不能关闭当前页面  
    string id = list[0].TestID;
                String Url = "f_MsgAlert.aspx?TestID=" + id.ToString();
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "redirectMe", "location.href='" + Url + "';", true);
    是打开f_MsgAlert.aspx这页了但是关闭了当前页面
      

  10.   

    首先缺人<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>有没有
    如果是在page_load里面的话代码如下:
    string strJS = "<script language='javascript' type='text/javascript'>";
                strJS += " fn_OpenMsgWindow('" + strTestID + "','_blank'); ";
                strJS += "</script>";
    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "winOpenJS", strJS, true);如果是button点击的话
    则在前台加上<Triggers> <asp:PostBackTrigger ControlID="button的ID" /> </Triggers> 
      

  11.   

    我想做的是 弹出一个新页面 并传递参数  但是不能关闭当前页面  
     string id = list[0].TestID;
                 String Url = "f_MsgAlert.aspx?TestID=" + id.ToString();
                 ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "redirectMe", "location.href='" + Url + "';", true);
     是打开f_MsgAlert.aspx这页了但是关闭了当前页面 
      

  12.   

    我想做的是 弹出一个新页面 并传递参数  但是不能关闭当前页面  
     string id = list[0].TestID;
                 String Url = "f_MsgAlert.aspx?TestID=" + id.ToString();
                 ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "redirectMe", "location.href='" + Url + "';", true);
     是打开f_MsgAlert.aspx这页了但是关闭了当前页面 
      

  13.   

    我想做的是 弹出一个新页面 并传递参数  但是不能关闭当前页面  
    ===
    可以用下面方法
    string js = "<script language = 'javascript'>";
    js += "window.open('"+strParam+"','_blank','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,left=0,top=64,Width=1012,Height=608');";
    js +="</script>";
      

  14.   

    或者用shouModalDialog 也行
    string id = list[0].TestID;
                 String Url = "f_MsgAlert.aspx?TestID=" + id.ToString();
    windows.shouModalDialog("+Url +"', '', 'dialogWidth:420px; dialogHeight:220px;status:no;help:yes')