Excel 自重定向.Asp页面并保留相同的请求变量
我试图将页面内容转换为Excel格式,问题是当我重定向页面时,我没有获取请求变量,因此我找到了一个解决方案,我们应该为每个请求变量定义一个隐藏变量,然后在get调用后定义值。这是我现在使用的代码:Excel 自重定向.Asp页面并保留相同的请求变量,excel,redirect,formatting,self,Excel,Redirect,Formatting,Self,我试图将页面内容转换为Excel格式,问题是当我重定向页面时,我没有获取请求变量,因此我找到了一个解决方案,我们应该为每个请求变量定义一个隐藏变量,然后在get调用后定义值。这是我现在使用的代码: <script language="Javascript"> function exportToExcel() { document.frm.hndExcel.value = "true"; document.frm.submit(); } </
<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>
函数exportToExcel()
{
document.frm.hndExcel.value=“true”;
document.frm.submit();
}
*
*
问题是,当我想在其他形式中使用此代码时,我需要为每个请求变量声明一个隐藏变量。是否有其他方法来概括此代码,以便在我们发回页面时保留相同的请求
谢谢。再一次,
经过一些尝试,我找到了一个不使用隐藏变量的通用解决方案,我们只需使用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>
函数exportToExcel()
{
document.frm.hndExcel.value=“true”;
document.frm.action='LibGetStatistics.asp?'+'';
document.frm.submit();
}
我希望这能帮助那些将要面对这个问题的人