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

File Download Tips for asp.net


use http header
protected void Page_Load(object sender, EventArgs e)
{
string format = Convert.ToString(ViewData["format"]);
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("·ÑÓñ¨Ïú±í", Encoding.UTF8) + string.Format(".{0}",format));
//²âÊÔÖз¢ÏÖ£ºÈç¹ûÒªÏëÔÚIEÖÐÖ±½Ó´ò¿ªPDF£¬ÉÏÐдúÂ룬²»ÄÜÓУ¡£¡·ñÔò¼´Ê¹¿Í»§¶ËÓÐÉèÖã¬Ò²»áʹÓà Adobe Reader/Acrobat ´ò¿ª
Response.ContentType = string.Format("application/{0}",format);
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.BinaryWrite(ViewData.Model);
Response.Flush();
//prevent render html to client(critical)
Response.End();
  
 
 
 request to doc directly
          Response.Redirect(“http://localhost:2222/Docs/abc.doc”, true);
 
Tips:
  ÖÁÓÚ¿Í»§¶ËʹÓÃä¯ÀÀÆ÷´ò¿ª(µ±È»±ØÐëÒªÏàÓ¦µÄä¯ÀÀÆ÷²å¼þÖ§³Ö)£¬»¹ÊÇÏàÓ¦µÄapplication (MS-Word,Adobe Reader),´ò¿ªÇ°ÊÇ·ñÌáʾÏÂÔØ£¬Server¶ËÊÇÎÞ·¨¿ØÖƵģ¬Õâ¸öºÍÓû§ÉèÖÃÓйØÏµ¡£¼ûͼ
 
 
 
 
 


Ïà¹ØÎĵµ£º

ASP.NETÖÐIfameµÄʹÓÃ

 Iframe±ê¼Ç£¬Óֽи¡¶¯Ö¡±ê¼Ç£¬Äã¿ÉÒÔÓÃËü½«Ò»¸öHTMLÎĵµÇ¶ÈëÔÚÒ»¸öHTMLÖÐÏÔʾ¡£Ëü²»Í¬ÓÚFrame±ê¼Ç×î´óµÄÌØÕ÷¼´Õâ¸ö±ê¼ÇËùÒýÓõÄHTMLÎļþ²»ÊÇÓëÁíÍâµÄHTMLÎļþÏ໥¶ÀÁ¢ÏÔʾ£¬¶øÊÇ¿ÉÒÔÖ±½ÓǶÈëÔÚÒ»¸öHTMLÎļþÖУ¬ÓëÕâ¸öHTMLÎļþÄÚÈÝÏ໥Èںϣ¬³ÉΪһ¸öÕûÌ壬ÁíÍ⣬»¹¿ÉÒÔ¶à´ÎÔÚÒ»¸öÒ³ÃæÄÚÏÔʾͬһÄÚÈÝ£¬¶ø²»±ØÖظ´Ð´ÄÚÈ ......

Asp.net×Ô¶¨ÒåÑéÖ¤¿Ø¼þCustomValidator µÄʹÓ÷½·¨

javascript º¯Êý ºÍ CustomValidator¿Ø¼þÏà½áºÏʹÓÃ
<asp:TextBox ID="txtPwdPrompt" runat="server"></asp:TextBox>
<asp:CustomValidator id="CVPwdPrompt" runat="server" ClientValidationFunction="CheckPwd" ControlToValidate="txtPwdPrompt" ErrorMessage="<span style='font:12px'>ÌáʾÎÊÌ ......

ASP.NETµÄʵÓôúÂë

1. ´ò¿ªÐµĴ°¿Ú²¢´«ËͲÎÊý£º

´«ËͲÎÊý£º
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
½ÓÊÕ²ÎÊý£º
string a = Request.QueryString("id");
string b = Request.QueryStrin ......

Asp.Netǰ̨µ÷Óúǫ́±äÁ¿

Asp.NetÖм¸ÖÖÏàËÆµÄ±ê¼Ç·ûºÅ: < %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Container.DataItem("tit") %>
< %= %>: ÔÚ³ÌÐòÖ´ÐÐʱ±»µ÷Ó㬿ÉÒÔÏÔʾºǫ́±äÁ¿Öµ
Èç:
*.aspxÖУº & ......

ÈçºÎÓÅ»¯ASP.NETÓ¦ÓóÌÐò£¿

 ¸Õ¿´µ½ÁËһƬÎÄÕ  http://dotnet.csdn.net/page/a92a1213-9896-49c7-9c89-14ae5f0d87ae    Ìáµ½Èçϼ¸µã:
1. Êý¾Ý¿âÁ¬½Ó³¬Ê±
2. ´´½¨µÄ¶ÔÏóÖ»¹ÜÓ㬲»¹ÜÊÍ·Å
3. µ÷ÊÔ(Debug)ģʽϱàÒëºó£¬¾ÍÓÃÓÚÓ¦Óû·¾³ÖÐÁË
4. ʵ¼Ê×÷ҵģʽ·ÖÏí
1,2,3±È½ÏºÃÀí½â£¬ÎÒÔÚ×öµÄʱºò·¸ÁËËû˵µÄ µÚÈýÖÖ´íÎó£¬ÖÁ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ