Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ASP.NETÏÂÔØÎļþ³öÏÖÌáʾ¿ò»òÕßÖ±½ÓÏÔʾÔÚä¯ÀÀÆ÷ÖÐ

ASP.NETÏÂÔØÎļþ³öÏÖÌáʾ¿ò»òÕßÖ±½ÓÏÔʾÔÚä¯ÀÀÆ÷ÖÐ
¼¼Êõ½»Á÷   2008-06-20 11:44   ÔĶÁ42   ÆÀÂÛ0  
×ֺţº ´ó´ó  ÖÐÖР СС
1£º³öÏÖÎļþÏÂÔØÌáʾ¿ò
string strFile="F:\\a.doc";//·¾¶¸ù¾Ýʵ¼ÊÇé¿ö¶ø¶¨
if(!System.IO.File.Exists(strFile))
  {
    Response.Write("<script language='javascript'>alert('¶Ô²»Æð£¬Îļþ²»´æÔÚ£¡');</script>");
    return;
  }
  Response.Clear();
  Response.ClearHeaders();
  Response.Charset = "GB2312";
  Response.ContentEncoding =System.Text.Encoding.UTF8;
  Response.ContentType = "application/octet-stream";
  FileInfo fi=new FileInfo(strFile);
  Response.AddHeader("Content-Disposition","attachment;  filename="  +  HttpUtility.UrlEncode(fi.Name)) ;
  Response.AddHeader("Content-Length",fi.Length.ToString());
  byte[] tmpbyte=new byte[1024*8];
  FileStream fs=fi.OpenRead();
  int count;
  while((count=fs.Read(tmpbyte,0,tmpbyte.Length))>0)
  {
    Response.BinaryWrite(tmpbyte);
    Response.Flush();
  }
  fs.Close(); 
  Response.End();
2£ºÖ±½ÓÔÚä¯ÀÀÆ÷Öдò¿ª
  string strFile="F:\\a.doc";//·¾¶¸ù¾Ýʵ¼ÊÇé¿ö¶ø¶¨
  Response.Clear();
  Response.ClearHeaders();
  Response.Charset = "GB2312";
  Response.ContentEncoding =System.Text.Encoding.UTF8;
  Response.ContentType = "application/msword";
  Response.WriteFile(strFile);
3£º·â×°³ÉÀàµÄÎļþÏÂÔØ·½·¨µÄд·¨
///
/// ÔÚÒ³ÃæÖÐÏÔʾÏÂÔØ¶Ô»°¿ò²¢ÏÂÔØÖ¸¶¨µÄÎļþ£¬webPageÎªÒ³Ãæ¶ÔÏóÒýÓã¨Ò»°ã¸³ÖµPage)£¬filePathΪÏÂÔØÎļþÐéÄâ·¾¶£¬fileNameΪ¶Ô»°¿òÖÐÏÔʾµÄÎļþÃû
///
public static void DownloadFile(Page webPage, string filePath, string fileName)
{
HttpResponse Response = webPage.Response;
FileInfo aFile = new FileInfo(webPage.Server.MapPath(filePath));
Response.Clear();
Response.ClearHeaders();
Response.BufferOutp


Ïà¹ØÎĵµ£º

40ÌõASP.NET¿ª·¢ÖªÊ¶

1¡¢ÔÚcompilation Ï£¬ÇëÉèÖÃdebug=false £¬ÈçÏ£º
default Language="c#" debug="false">
2¡¢ÇëʹÓÃServer.Transfer´úÌæResponse.Redirect¡£
3¡¢Ê¹ÓÃValidator¿Ø¼þ£¬ÇëÒª¾­³£¼ì²éPage.IsValid¡£
4¡¢ÇëʹÓÃforeachÑ­»·£¬¶ø²»ÊÇΪ×Ö·û´®µü´úÑ­»·¡£
5¡¢ÇëʹÓÿͻ§¶ËÑéÖ¤·½Ê½(²»ÒªÃ¿´Î¶ ......

SilverlightÓ¦ÓóÌÐòÖÐÈçºÎ»ñÈ¡ASP.NETÒ³Ãæ²ÎÊý

¸ÅÊö
ÔÚ¿ª·¢SilverlightÓ¦ÓóÌÐòʱ£¬ÎÒÃǾ­³£»áÓöµ½ÕâÑùÒ»ÖÖÇé¿ö£¬ÐèÒªÔÚSilverlightÓ¦ÓóÌÐòµÄUserControlÖлñÈ¡ASP.NETÒ³Ãæ²ÎÊý£¬Õâ¸ö²ÎÊý²»Ò»¶¨À´×ÔÓÚµ±Ç°SilverlightÓ¦ÓóÌÐòµÄËÞÖ÷Ò³Ãæ£¬¶øÓпÉÄÜÀ´×ÔÓÚÆäËüµÄASP.NETÒ³Ãæ¡£
±¾ÎÄÎÒÃǼòµ¥µÄ½éÉÜÒ»ÏÂÈçºÎÔÚSilverlightÓ¦ÓóÌÐòÖлñÈ¡ASP.NETÒ³Ãæ²ÎÊý¡£
ÐèÇó
ÈçÏÂÃæµÄ ......

asp.net C#ÃüÃû²ÎÊýSqlParameterÏê½â

DBHelper:
         /// <summary>
        /// Ö´Ðвéѯ
        /// </summary>
        /// <param name="sql">ÓÐЧµÄselectÓï¾ä</param ......

asp.net(c#) ÏÂSQL´æ´¢¹ý³ÌʹÓÃÏêϸʵÀý

¼ÇÈ¡¼Ç¼¼¯
create procedure getArticle
as
select * from Article_Content
GO
asp.net µ÷Ó÷½·¨
  SqlConnection Conn = new SqlConnection();
        Conn.ConnectionString = Data.Connstr();
        Conn.Open();
  ......

ASP.NETÖÐʹÓ÷ÖÀàÒ³²½Öè

µÚÒ»²½£º´´½¨¶ÔÏó
µÚ¶þ²½£ºÉèÖÃÊôÐÔ
¢ÙpdsBooks.AllowPaging=true;
¢ÚpdsBooks.PageSize=5;
¢ÛpdsBooks.CurrentPageIndex=CurrentPage-1;
¢ÜpdsBooks.DataSource=BookManage.GetAllBooks();
µÚÈý²½£º°ó¶¨Êý¾ÝÔ´
DataList1.DataList=pdsBooks;
DataList1.DataBind(); ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ