自我重定向.Asp页面并保持相同的Request变量

时间:2023-01-14 16:23:50

Am trying to convert the content of a page to an Excel format, the problem is when I redirect the page I don't get my request variables so I found a solution that we should define a hiden variable for each request variable and then define the value after Get call. This is the code that am using now :

我试图将页面内容转换为Excel格式,问题是当我重定向页面时我没有得到我的请求变量所以我找到了一个解决方案,我们应该为每个请求变量定义一个hiden变量然后定义获得电话后的价值。这是我现在使用的代码:

<script language="Javascript">
   function exportToExcel()
   {
     document.frm.hndExcel.value = "true";
     document.frm.submit();
   }
</script>


<form name="frm" method="get" action="LibGetStatistics.asp" ID="Form1">
 <% if Request.QueryString("hndExcel") = "true" then
    Response.ContentType = "application/vnd.ms-excel"
 end if%>

 <%= GetStatistics() %>
  <input type="hidden" name="hndExcel" value="false" ID="Hidden1">
  *<input type="hidden" name="ShowOverDueBooks" value="
         <%=Request.QueryString "ShowOverDueBooks")%>" ID="Hidden2">
  <input type="hidden" name="StartDate" value="
         <%=Request.QueryString("StartDate")%>" ID="Hidden3">
  <input type="hidden" name="EndDate" value="
         <%=Request.QueryString("EndDate")%>" ID="Hidden4">*

 <a href="JavaScript:exportToExcel();"><img src='vimages/excel.gif' border=0></a>
</form>

The problem is when I want to use this code in other forms I need to declare a hidden variable for each Request variables. Is there any other way to generalize this code so when we post back the page we keep the same request.

问题是,当我想以其他形式使用此代码时,我需要为每个Request变量声明一个隐藏变量。是否有任何其他方法来概括此代码,所以当我们回发页面时,我们保持相同的请求。

Thanks.

1 个解决方案

#1


Again, After some trys I found a general solution that don't use the hidden variables, we have just to use the Request.QueryString property :

再次,经过一些尝试,我找到了一个不使用隐藏变量的通用解决方案,我们只需要使用Request.QueryString属性:

<script language="Javascript">
function exportToExcel()
{
    document.frm.hndExcel.value = "true";
    document.frm.action='LibGetStatistics.asp?' + '<%=Request.QueryString%>';
    document.frm.submit();
}
</script>


<form name="frm" method="post"  ID="Form1">
    <input type="hidden" name="hndExcel" value="false" ID="Hidden1">
    <% if Request.Form("hndExcel") = "true" then
        Response.ContentType = "application/vnd.ms-excel"
    end if%>

    <%= GetStatistics() %>
          <a href="JavaScript:exportToExcel();">
              <img src='vimages/excel.gif' border=0></a>
</form>

I hope that should help people who will face this problem.

我希望能帮助那些将面临这个问题的人。

#1


Again, After some trys I found a general solution that don't use the hidden variables, we have just to use the Request.QueryString property :

再次,经过一些尝试,我找到了一个不使用隐藏变量的通用解决方案,我们只需要使用Request.QueryString属性:

<script language="Javascript">
function exportToExcel()
{
    document.frm.hndExcel.value = "true";
    document.frm.action='LibGetStatistics.asp?' + '<%=Request.QueryString%>';
    document.frm.submit();
}
</script>


<form name="frm" method="post"  ID="Form1">
    <input type="hidden" name="hndExcel" value="false" ID="Hidden1">
    <% if Request.Form("hndExcel") = "true" then
        Response.ContentType = "application/vnd.ms-excel"
    end if%>

    <%= GetStatistics() %>
          <a href="JavaScript:exportToExcel();">
              <img src='vimages/excel.gif' border=0></a>
</form>

I hope that should help people who will face this problem.

我希望能帮助那些将面临这个问题的人。