随笔分类 - asp.net
摘要:1.js代码function uploadFile() { var str = '' document.getElementById('MyFile').insertAdjacentHTML("beforeEnd", str) }2.页面含义html代码(页面必须含有一个runat=“server”的file对象) 3.后台页面代码 public bool attachfileupload() { Hashtable ht = new Hashtable(); HttpFileCollection files = HttpContext.Cu
阅读全文
摘要:首先建立一个超链接其中超链接href转到Download.aspx,接着,在DownloadFile.aspx页面中使用string fileid = Request.QueryString["fileid"]; string filename = Request.QueryString["filename"]; string filepathname = Server.MapPath(@"~/upload/") + fileid; Response.Clear(); Response.ClearHeade...
阅读全文
摘要:1.对于txt,html等文本文件可以使用streamreader的方式读取,生成string类型2.对于图像、图片类型则使用filestream的方式读取后生成byte[]3.对于response.writefile("path"),则是把文件内容读取到响应输出流(内容可以是一个jpp文件,或者是html,txt文件等等)
阅读全文
摘要:.NET二进制图片存储与读取的常见方法有以下几种:.NET二进制图片存储:以二进制的形式存储图片时,要把数据库中的字段设置为Image数据类型(SQL Server),存储的数据是Byte[].1.参数是图片路径:返回Byte[]类型:publicbyte[] GetPictureData(string imagepath) { /**/////根据图片文件的路径使用文件流打开,并保存为byte[] FileStream fs = new FileStream(imagepath, FileMode.Open);//可以是其他重载方法 byte[] byData = newbyte[fs...
阅读全文
摘要:Response.Charset ASP.NET 中示例: CodePage 告诉 IIS 按什么编码来读取 QueryString,按什么编码转换数据库中的内容……Response.ContentEncoding获取或设置输出流的 HTTP 字符集。Response.Charset获取或设置输出流的 HTTP 字符集。微软对 ContentEncoding、Charset 的解释是一字不差,其实可以这样理解:ContentEncoding 是标识这个内容是什么编码的,而 Charset 是告诉客户端怎么显示的。我们可以做一个实验来理解:实验1.Response.ContentEncodi..
阅读全文
摘要:1. //服务器端rendercontrol生成word文档 #region //HttpContext.Current.Response.Clear(); //HttpContext.Current.Response.Charset = "UTF-8"; //HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=导出文档.doc"); //HttpContext.Current.Response.ContentEnco
阅读全文
摘要:ASP.NET中的post和get请求操作主要是为了测试一下当post请求中有get参数的时候,服务器端是如何处理这两种不同的参数的。是一起当post参数处理,还是分开处理。客户端post_test.html Post_Get Test 服务器端 Default.aspx 服务器端Default.aspx.csusing System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.U...
阅读全文
摘要:我们在使用SqlDataSource进行并发策略的时候比较容易实现,通过设置ConflictDetection值为CompareAllValues,OldValuesParameterFormatString="original_{0}"就可以在SelectCommand,UpdateCommand,DeleteCommand里面进行设置即可。设计Account(AccountID,Account...
阅读全文
浙公网安备 33010602011771号