Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

´ø±à¼­µÄÏÂÀ­¿òasp.net

ÐÞ¸ÄÁË´Ó£ºhttp://www.cnblogs.com/ejiyuan/archive/2007/11/09/954325.htmlµÄÒ»ÅúÎÄÕ Éú³ÉÁË¿ÉÒÔÔÚGridviewÀïÃæµ÷ÓõÄCombBox¿Ø¼þ£¬ÊÇ»ùÓÚAjaxµÄ¡£
    ¶ÀÁ¢Ê¹ÓÃʹÓ÷½Ê½£¨£©£º  <Com:ComboBox ID="ComboBox2" runat="server" Independent="true"  Width="80px" EnableViewState="true"> ......

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

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

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Öг£ÓõĴ洢¹ý³Ì


1.²éѯ¹¦ÄÜ£º
ÃèÊö£ºÍ¨³£ÔÚÍøÒ³Éϸù¾Ýµã»÷²éѯ°´Å¥»ñµÃËùÒª½á¹û
Àý£º
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author:±ù˪
-- Create date: 2009-09-04
-- Description:²éѯ
-- =============================================
Alter PROCEDURE ......

ASP.NETÍøÒ³µÄ´¦Àí¹ý³Ì

     ASP.NETµÄ¹Ø¼üÄ¿±êÖ®Ò»ÊÇ´´½¨Ò»ÖÖÈÿª·¢ÈËÔ±Äܹ»ÏñWindowsÓ¦ÓóÌÐò¿ª·¢Õß¶¨ÖÆ×ÀÃæÓ¦ÓóÌÐòÄÇÑùµÄ¿ìËÙ¶¨ÖÆWeb FormsµÄģʽ¡£µ±È»WebÓ¦ÓóÌÐòÓ봫ͳ¸»¿Í»§¶ËÓ¦ÓóÌÐòÓкܴóµÄ²»Í¬£¬ÒªÊµÏÖÕâÖÖģʽÓÐÁ½¸ö¹Ø¼üµÄÕϰ­¡£
     1.WebÓ¦ÓóÌÐòÊÇÔÚ·þÎñÆ÷¶ËÖ´ÐеģºÀýÈ磬¼ÙÉè´´½¨Ò»¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ