我想实现用linkbutton实现和hyperlink一样的连接效果(页面自动打开,文件自动下载),点击连接存储下载记录信息,并实现连接效果。
我用了两种方法,效果都不好:
1)用linkbutton,在click事件中加了脚本代码:
存储数据;
Response.Write("<script language=javascript>window.open('" + ColumnValue[4] + "','_blank')</script>");可在xp上使用有问题,我查了一下原因,是xp本身问题:
不能使用 Window.Open 方法打开或下载一个基于 Windows XP Service Pack 2 的计算机上的一个文件
所以要避开这个方法2)用hyperlink转到数据处理页,存储数据,用response.redirect("test.asp");转向链接页面,但也有问题,我的链接页面数据是从别人的数据库以xml形式得到的,如果只传ID,需要重新查找数据,运行很慢;如果所有数据都传过来,链接地址串又会超常,而且有非法字符。
请问有什么好办法能够一点连接,能够存储点击记录的所有数据,又能很快地转向链接页面?
我用了两种方法,效果都不好:
1)用linkbutton,在click事件中加了脚本代码:
存储数据;
Response.Write("<script language=javascript>window.open('" + ColumnValue[4] + "','_blank')</script>");可在xp上使用有问题,我查了一下原因,是xp本身问题:
不能使用 Window.Open 方法打开或下载一个基于 Windows XP Service Pack 2 的计算机上的一个文件
所以要避开这个方法2)用hyperlink转到数据处理页,存储数据,用response.redirect("test.asp");转向链接页面,但也有问题,我的链接页面数据是从别人的数据库以xml形式得到的,如果只传ID,需要重新查找数据,运行很慢;如果所有数据都传过来,链接地址串又会超常,而且有非法字符。
请问有什么好办法能够一点连接,能够存储点击记录的所有数据,又能很快地转向链接页面?
解决方案 »
- 高手请进!!!
- 如何利用SQLDMO把一个bak备份新建一个数据库?
- HtmlTable在c#中 background属性有吗?
- Response.End() 与 return 等价?
- 求助:调用图表控件出错,找不到指定的模块
- 关于在 Internet Explorer 中使用 Windows 窗体控件
- LinkButton操作历史记录的问题!
- 高人看一下 谢谢
- 能不能让服务器段button按钮的事件每20秒自动执行一次(不允许用刷新的方法)
- 请问如何在显示的datagrid的页面中将datagrid的超链接列传递参数
- 如何在asp.net .cs 中 写代码,页面跳转到指定的iframe(救命啊 !!!)
- Multiview 中的View中动态添加控件不能显示
用ASP写的我没有类似代码.ASP.NET的类似这样 System.IO.FileInfo file = new System.IO.FileInfo(fileName);
if (file.Exists)
{
System.IO.FileStream fs = null;
fs = System.IO.File.Open(fileName, System.IO.FileMode.Open);
byte[] btFile = new byte[fs.Length];
fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
fs.Close(); System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
System.Web.HttpContext.Current.Response.ContentType = "audio/mpeg3";
System.Web.HttpContext.Current.Response.BinaryWrite(btFile);
}
else
{
System.Web.HttpContext.Current.Response.Write("This file does not exist.");
}
具体文件类型请参照 MIME类型确定.在那代码上面操作记录
我试试,这个好像是在本页打开,我需要像链接一样在新的窗口打开。
数据不是很大的话也可以用cookie
第二个问题,表单提交方式改成Post
-----------------------
非要转到test.asp存储数据吗?在本页处理,把数据存入session,再转页,这个页就不用重新搜了,直接session里取
<a href="http://www.onejoo.com:8000/" target=_blank class=l onmousedown="return clk(0,'','','res','4','')"><font color=CC0033>玩聚</font>
最好有个现成的例子,谢谢!
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug">
<Services>
<asp:ServiceReference Path="WebServiceFoundation.asmx" InlineScript="true" />
</Services>
</asp:ScriptManager>
<input type="button" value="Get Random" onclick="getRandom()" />
<input type="button" value="Get Range Random" onclick="getRandom(0, 9)" />
<script language="javascript" type="text/javascript">
function getRandom(minValue, maxValue)
{
if (arguments.length != 2)
{
Sample.WebServiceFoundation.GetRandom(getRandomSucceeded);
}
else
{
Sample.WebServiceFoundation.GetRangeRandom(minValue, maxValue, getRandomSucceeded);
}
}
function getRandomSucceeded(result)
{
alert(result);
}
</script>
</form>
<%@ WebService Language="C#" Class="Sample.WebServiceFoundation" %>using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;namespace Sample
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class WebServiceFoundation : System.Web.Services.WebService
{
[WebMethod]
public int GetRandom()
{
return new Random(DateTime.Now.Millisecond).Next();
} [WebMethod]
public int GetRangeRandom(int minValue, int maxValue)
{
int a = new Random(DateTime.Now.Millisecond).Next(minValue, maxValue);
int b = new Random(DateTime.Now.Millisecond).Next(minValue, maxValue);
int c = new Random(DateTime.Now.Millisecond).Next(minValue, maxValue);
return a + b + c;
}
}
}