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

ASP.NET MVC Uploading and Downloading Files


If you come to ASP.NET MVC from a purely ASP.NET Web Forms background, one of the first things you are likely to notice is that all those nice easy Server Controls have disappeared. One of those is the FileUpload, and its absence seems to cause a few problems. This article looks at how to upload files to the server in an MVC world, and how to get them back from the server to the user again.
 
In Web Forms, when you drag a FileUpload control on to the designer, something happens when the page is rendered which you probably don't notice. The resulting html form that wraps the entire page is decorated with an extra attribute: enctype="multipart/form-data". The FileUpload itself is rendered as an html input type=file. Within an MVC View, there are a number of ways to set this up. The first is with HTML:
<form action="/" method="post" enctype="multipart/form-data">
<input type="file" name="FileUpload1" /><br />
<input type="submit" name="Submit" id="Submit" value="Upload" />
</form>
Notice that the <form> tag includes the enctype attribute, and method attribute of post. This is needed because the form by default will be submitted via the HTTP get method.  The following approach, using the Html.BeginForm() extension method renders the exact same html when the page is requested:
<%
using (Html.BeginForm("", "home", FormMethod.Post, new {enctype="multipart/form-data"}))
{%>
<input type="file" name="FileUpload1" /><br />
<input type="submit" name="Submit" id="Submit" value="Upload" />
<% }%>
Notice the name attribute of the <input type="file"> element. We'll come back to that shortly. In the meantime, the resulting page should look rather blandly like this:
OK. So we can now browse to a local file and click the submit button to upload it to the web server. What is needed next is some way to manage the file on the server. W


Ïà¹ØÎĵµ£º

dz̸ASP.net°²È«±à³Ì

ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......

ASP.NET¾­µäÃæÊÔÌâ

1. ¼òÊö private¡¢ protected¡¢ public¡¢ internal ÐÞÊηûµÄ·ÃÎÊȨÏÞ¡£
´ð . private : ˽ÓгÉÔ±, ÔÚÀàµÄÄÚ²¿²Å¿ÉÒÔ·ÃÎÊ¡£
protected : ±£»¤³ÉÔ±£¬¸ÃÀàÄÚ²¿ºÍ¼Ì³ÐÀàÖпÉÒÔ·ÃÎÊ¡£
public : ¹«¹²³ÉÔ±£¬ÍêÈ«¹«¿ª£¬Ã»ÓзÃÎÊÏÞÖÆ¡£
internal: ÔÚͬһÃüÃû¿Õ¼äÄÚ¿ÉÒÔ·ÃÎÊ¡£
£¨partial ÔÊÐí½«Àà¡¢½á¹¹»ò½Ó¿ÚµÄ¶¨Òå²ð·Öµ½¶à¸ ......

ÕýÈ·ÈÏʶWebFormÓëAsp.NET MVC

1.´«Í³WebForm¿ª·¢ÖдæÔÚµÄһЩÎÊÌâ
 ´«Í³µÄASP.NET¿ª·¢ÖУ¬Î¢ÈíµÄ¿ª·¢ÍŶÓΪ¿ª·¢ÕßÉè¼ÆÁËÒ»¸öÔÚ¿ÉÊÓ»¯Éè¼ÆÆ÷ÖÐÍϷſؼþ£¬±àд´úÂëÏìӦʼþµÄ¿ìËÙ¿ª·¢»·¾³¡£È»¶ø£¬ËüËù´øÀ´µÄ¸ºÃæЧӦÊÇ£º 
 ÓÉÓڿؼþ·â×°Á˺ܶණÎ÷£¬¿ª·¢ÕߺÜÄÑÁ˽âÕâ±³ºóµÄHTMLÊÇÈçºÎÔË×÷µÄ
ÈÝÒ׵õ½Ò»¸ö°üº¬´óÁ¿ViewStateµÄÒ³Ã棬ʹµÃÒ ......

FCKeditor ÔÚASP.Net ÖеÄʹÓÃ˵Ã÷


FCKeditor ÔÚASP.Net ÖеÄʹÓÃ˵Ã÷
[ 2008-7-23 23:41:00 | By: »ª×Ó ]
 
2
ÍƼö
 
FCKeditor ÊÇÒ»¸öÔËÐÐÔÚä¯ÀÀÆ÷É쵀 Java Ó¦ÓóÌÐò¡£Ëû¿ÉÒÔ²»ÒÀÀµÈκηþÎñÆ÷¶ËÓïÑÔÔËÐС£²»¹ý£¬¸üºÃµÄʹÓ÷½·¨ÊÇÄãʹÓÃÒ»ÖÖ·þÎñÆ÷¶ËÓïÑÔÀ´µ÷ÓÃËû¡£
ÔÚASP.Net ÖУ¬ÓÐÒ»¸öÏֳɵŤ¾ß°ü¿ÉÒÔÈÃÄã°Ñ FCKeditor ×÷Î ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ