我通过主页中的搜索按钮用
Response.Write("<Script>window.open('search.aspx?search="+this.search1.SelectedIndex.ToString()+"&word="+this.keyword.Text.Trim()+" target=_blank')</script>");
弹出一个窗口,怎样能让够再刷新主页的时候不在弹出它呢!!!

解决方案 »

  1.   

    用session记录一下是否已经弹出过
      

  2.   

    设置一个标示符,在该窗口的load事件中为标示符赋值,在窗体的dispose事件中将该值清空
    ,显示窗体时,判断标示符
      

  3.   

    用Session["IsFresh"]="0";
    if (Session["IsFresh"].ToString()=="0")

      Response.Write("<Script>window.open('search.aspx?search="+this.search1.SelectedIndex.ToString()+"&word="+this.keyword.Text.Trim()+" target=_blank')</script>");
    }
    else
    {
      Response.Write("<Script>location.href='search.aspx'</script>");
    }
      

  4.   

    liulxmoooo,能给个例子么,我是新手
      

  5.   

    飞狐,
    response.write已经把脚本写到页面了,用不用session好象都没效果的不知道我说的对不对
      

  6.   


    如果在Page_Load中
    private void Page_Load(object sender, System.EventArgs e)
    {
     if(!(IsPostBack))
    {
    Response.Write("<Script>window.open('search.aspx?search="+this.search1.SelectedIndex.ToString()+"&word="+this.keyword.Text.Trim()+" target=_blank')</script>");
    }
    }
    如果?写在 Button1_Click 事件,刷新是不会运行的
      

  7.   

    如果你的这段这段代码:
    (Response.Write("<Script>window.open('search.aspx?search="+this.search1.SelectedIndex.ToString()+"&word="+this.keyword.Text.Trim()+" target=_blank')</script>");

    在Page_Load中在代码前加:  if(!(IsPostBack))
    {
                                }
      

  8.   

    还有一个办法就是记录SessionID的值,在刷新页面的时候判断是否相等再弹出页面
      

  9.   

    to snowmans
      代码是写在private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)事件中的,该怎么做呢?to 可乐   劳烦给段代码看,谢谢!
      

  10.   

    是我菜拉,算了,那就不用弹出新窗口表现搜索的内容了
    直接
    this.Response.Redirect("search.aspx?search="+this.search1.SelectedIndex.ToString()+"&word="+this.keyword.Text.Trim()+"");
      

  11.   

    因为
    Response.Write("<Script>window.open('search.aspx?search="+this.search1.SelectedIndex.ToString()+"&word="+this.keyword.Text.Trim()+" target=_blank')</script>");
    已经将这段javascript 写入到客户浏览器 所以你刷新就会显示出来解决办法:
    在主页的Page_Load中
    private void Page_Load(object sender, System.EventArgs e)
    {
    this.Button1.Attributes.Add("onclick","JavaScript:return Test('WebForm2.aspx?aa=123')");
    }
    然后在Html 中加入:
    <script language="javascript">
    function Test(ss)
    {
                        window.open(ss);
                    }
                    
    </script>
    就可以了,按钮选执行客户端事件,然后在执行服务器端事件
      

  12.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    // ページを初期化するユーザー コードをここに挿入します。
    //this.Button1.Attributes.Add()
    string path="search.aspx?search="+this.search1.SelectedIndex.ToString()+"&word="+this.keyword.Text.Trim()+" target=_blank";
    this.Button1.Attributes.Add("onclick","JavaScript:return Test('" + path + "')");
    }
      

  13.   



    window.opener.location.reload();
    window.opener.location.href=window.opener.location.href
    去刷新(其实是重定位了一下)父窗口
      

  14.   

    用cookie 来写吧。。
     session  写的话 浪费大大的资源  而且没有必要