前台代码如下
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="query2.aspx.cs" Inherits="query2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function SearchAll1(cata) {
            var strkey = document.getElementById("tkey").value;
            var href = "/query2.aspx?cata=" + cata + "&key=" + strkey;
            window.location.href = href;
        }
    </script>
</head>
<body >
    <form id="form1" >
         <input id="tkey" name="tkey" type="text"  />
         <button  id="search" onclick="SearchAll1('all')"></button>
    </form>
</body>
</html>
后台代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;public partial class query2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = Request.RawUrl;
    }
  
}

解决方案 »

  1.   

    var strkey = document.getElementById("tkey").value;
      var href = "/query2.aspx?cata=" + cata + "&key=" + strkey;
      window.location.href = href;script中的这个跳转是同一个页面吗?
      

  2.   

    是的,跳转是同一个页面query2.aspx
      

  3.   

    用户的key用requeat.querystring["key"]来截取 cata类似 你看看怎么样 
      

  4.   

    我换了调试环境,发现在火狐下还是执行两次,ie6下是一次,在ff下,重复的请求了一次页面,是什么原因呢
      

  5.   

    <head>里为什么加了个runat?JavaScript代码不加runat也可以执行的吧
      

  6.   

    lz的这个本来就要执行两次的。首先你加载的时候要执行一次,然后你加载的时候你的js里面又有个  window.location.href = href;这个时候又跳转到本页面,这时候又执行了一次。
      

  7.   

    晕,点击按钮搜索时,是html控件,执行js脚本,是不会引发Page_Load事件的我再一次强调,在ie6下是正常的,点击按钮,Page_Load加载一次,在ff火狐下Page_Load加载两次,不知道为什么重复请求了一次,代码已贴上,请拿实验结果说话
      

  8.   

    可能是<button id="search" onclick="SearchAll1('all')"></button>出了问题
      

  9.   

    页面加载的时候 执行了一次   点击按钮时候执行了一次  这样有问题?   
    我的也是IE8 测试没问题  
    点击按钮最后得的值是 url = /3274/query2.aspx?tkey=%E6%B5%8B%E8%AF%95
    有问题?这样不就可以取到你要的参数了吗!
      

  10.   

    点击按纽不要使用button,用一个链接<a href="javascript:void(0)" onclick="SearchAll1('all')">搜索</a>
    你用button,默认是提交页面的表单了,同时点击的时候有激发了searchall这个过程,又提交了一次