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

ASP.NETÖÐÎļþÉÏ´«¿Ø¼þ

 <asp:FileUpload /> ÎļþÉÏ´«¿Ø¼þ
 ÊµÏÖÒ»¸ö¼òµ¥µÄͼƬÎļþÉÏ´«
 //ÉÏ´«Îļþ¿Ø¼þʹÓãºÊµÏÖÉÏ´«Í¼Æ¬¹¦ÄÜ£¬ÉÏ´«Í¼Æ¬Ö»ÄÜÊÇjpg£¬gif£¬bmpÈýÖÖÀàÐÍ£¬Í¼Æ¬´óС²»³¬¹ý60kb
ºǫ́´úÂ룺
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
imgForFileUp.Visible = false;
}
}
protected void btUp_Click(object sender, EventArgs e)
{
bool isAllow = false; //ÊÇ·ñÔÊÐíÉÏ´«£¬Ä¬ÈÏΪfalse
string path = Server.MapPath("image/"); //ÉÏ´«Îļþ±£´æ·¾¶ (Ïà¶Ô·¾¶)
if (fileUp.HasFile) //FileUpload¿Ø¼þ²»Îª¿Õ
{
string fileType = System.IO.Path.GetExtension(fileUp.FileName).ToLower(); //ÎļþÀàÐÍ
string[] allowFile = { ".jpg", ".gif", ".bmp" };// ¶¨ÒåÔÊÐíÉÏ´«µÄÎļþÀàÐÍ
for (int i = 0; i < allowFile.Length; i++)
{
if ((fileType == allowFile[i]) && fileUp.PostedFile.ContentLength <= 60 * 1024)
{
isAllow = true; //ÉèΪtrue £¬¼´ÔÊÐíÉÏ´«
}
}
}
else
{
lbForFileUp.Text = "ÇëÉÏ´«Îļþ!!!";
}
if (isAllow == true)
{
try
{
//ÒÔʱ¼äÀ´ÖØÃüÃûͼƬÎļþÃû
//string newName = DateTime.Now.ToFileTime() + "." + fileType;
//±£´æÎļþµ½·þÎñÆ÷
fileUp.PostedFile.SaveAs(path + fileUp.FileName);
//ÌáʾÐÅÏ¢
lbForFileUp.Text = "ÉÏ´«³É¹¦!!!";
//ÏÔʾͼÆ


Ïà¹ØÎĵµ£º

asp.netÖÐwordתhtmlÅöµ½µÄȨÏÞÒì³£ÎÊÌâ


¼ìË÷ COM À๤³§ÖÐ CLSID Ϊ {000209FF-0000-0000-C000-000000000046} µÄ×é¼þʱʧ°Ü£¬Ô­ÒòÊdzöÏÖÒÔÏ´íÎó: 80070005¡£
˵Ã÷: Ö´Ðе±Ç° Web ÇëÇóÆڼ䣬³öÏÖδ´¦ÀíµÄÒì³£¡£Çë¼ì²é¶ÑÕ»¸ú×ÙÐÅÏ¢£¬ÒÔÁ˽âÓйظôíÎóÒÔ¼°´úÂëÖе¼Ö´íÎóµÄ³ö´¦µÄÏêϸÐÅÏ¢¡£
Òì³£ÏêϸÐÅÏ¢: System.UnauthorizedAccessException: ¼ìË÷ COM À๤ ......

ASP.NET MVC ÈëÃÅ

ViewDataÓÐÒ»¸öModelStateµÄÊôÐÔ£¬ÕâÊÇÒ»¸öÀàÐÍΪModelStateDictionaryµÄModelStateÀàÐ͵Ä×ֵ伯ºÏ¡£ÔÚ½øÐÐÊý¾ÝÑéÖ¤µÄʱºòÕâ¸öÊôÐÔÊDZȽÏÓÐÓõġ£ÔÚʹÓÃHtml.ValidationMessage()µÄʱºò£¬¾ÍÊÇ´ÓViewData.ModelStateÖмì²âÊÇ·ñÓÐÖ¸¶¨µÄKEY£¬Èç¹û´æÔÚ£¬¾ÍÌáʾ´íÎóÐÅÏ¢¡£ÀýÈçÔÚǰһƪÎÄÕÂASP.NET MVC ÈëÃÅ7¡¢HellperÓëÊý¾ÝµÄÌá ......

¶¨ÖÆASP.Net MVCµÄ´úÂëÄ£°å

ÔÚASP.Net MVCÀàÐ͵ÄÏîÄ¿ÖÐÓÒ»÷Controller Îļþ¼Ð£¬Ñ¡ÖÐAdd=>Controller¡­ºó£¬»áÔÚн¨µÄController ÖвåÈëһЩĬÈÏ´úÂë¡£   ÔÚController µÄ¸÷¸öAction·½·¨ÖÐÓÒ»÷ Add View¡­£¬Ò²»áÔÚн¨µÄViewÖвåÈëһЩ´úÂë¡£ÔÚн¨Viewʱ²åÈëµÄ´úÂë»á¸ù¾ÝÉÏÏÂÎĺÍÄãµÄÑ¡Ôñ¶ø²»Í¬£¬ËƺõÓкܴóµÄ´úÂëÉú³É¹¦ÄÜ¡£ ÉÏÊöÁ½ÕßÉú³É´ ......

ASP.NET LINQ _1

 Ê²Ã´ÊÇLINQ?
       LINQÊÇÓïÑÔ¼¯³É²éѯ(Language Integrated Query)µÄ¼ò³Æ£¬ÊÇVisual Studio 2008 ºÍ.NET Framework 3.5 °æÖÐÒ»Ïî,Í»ÆÆÐԵĴ´Ð£¬ËüÔÚ¶ÔÏóÁìÓòºÍÊý¾ÝÁìÓòÖ®¼ä¼ÜÆðÁËÒ»×ùÇÅÁº.
       Ò»¸ö¼òµ¥LINQ²éѯ£º
    &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ