asp.net 用流的方式下载文件
//以下代码根据别人文章和自己整理
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace WebApplication1
{
public partial class DownfFile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// WriteFile下载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
string name ="DreamweaverCS3简体中文免激活绿色版.rar";
string path =Server.MapPath("DreamweaverCS3简体中文免激活绿色版.rar");
FileInfo fileinfo = new FileInfo(path);
long size = fileinfo.Length;
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + name);
Response.AppendHeader("Content-Length", size.ToString());
Response.AppendHeader("Content-Transfer-Encoding", "binary");
Response.ContentEncoding = System.Text.Encoding.UTF8;//GetEncoding("gb2312");
Response.WriteFile(path,0,size);
Response.Flush();
Response.End();
}
/// <summary>
/// 使用OutputStream.Write分块下载文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button2_Click(object sender, EventArgs e)
{
string fileName = HttpContext.Current.Server.UrlEncode("DreamweaverCS3简体中文免激活绿色版.rar");
string filePath = HttpContext.Current.Server.MapPath("DreamweaverCS3简体中文免激活绿色版.rar");
//如果要写类的话用HttpResponse h
相关文档:
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.为按钮添加对话框
Button1 ......
这是要实现的功能:
第一步:拖入GridView控件 并且完成查询所有数据的方法 通过this.GridView1.DataSource 获取集合数据 GridView1.DataBind() 绑定数据
第二步:实现全选功能
1. 页面代码:
代码
<asp:TemplateField HeaderText="全选">
&nbs ......
"服务器名称:"+Server.MachineName;//服务器名称
"服务器IP地址:" + Request.ServerVariables["LOCAL_ADDR"];//服务器IP地址
&nbs ......
asp.net 获取html控件的值的代码如下:
WebForm1.aspx:
< INPUT ID="TXT" TYPE="TEXT" RUNAT="SERVER" VALUE="AAAAAA">
< INPUT TYPE="BUTTON" RUNAT="SERVER" VALUE="BTNTEST" ID="BUTTON1"&nb ......
刚毕业,最近在搞毕业论文。
说起毕业论文我就头疼,我们三人一组,本来我主张用C#写,套用一个外国的模型BalloonShop在线购物网站,C#是自学的。但是同组的一个同学VB学得不错,要用VB。我想你要用VB写的话我是不太懂,那只能你自己写好了,我最多也就搭把手而已,省心了,何乐而不为呢!
最后作品做出来还算不错,就 ......