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 = "ÉÏ´«³É¹¦!!!";
//ÏÔʾͼÆ
Ïà¹ØÎĵµ£º
¼ìË÷ COM À๤³§ÖÐ CLSID Ϊ {000209FF-0000-0000-C000-000000000046} µÄ×é¼þʱʧ°Ü£¬ÔÒòÊdzöÏÖÒÔÏ´íÎó: 80070005¡£
˵Ã÷: Ö´Ðе±Ç° Web ÇëÇóÆڼ䣬³öÏÖδ´¦ÀíµÄÒì³£¡£Çë¼ì²é¶ÑÕ»¸ú×ÙÐÅÏ¢£¬ÒÔÁ˽âÓйظôíÎóÒÔ¼°´úÂëÖе¼Ö´íÎóµÄ³ö´¦µÄÏêϸÐÅÏ¢¡£
Òì³£ÏêϸÐÅÏ¢: System.UnauthorizedAccessException: ¼ìË÷ COM À๤ ......
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯¡¡
¡¡
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ ......
1¡¢¸øɾ³ý°´Å¥Ìí¼ÓÊÇ·ñÈ·ÈÏÌáʾ£º
ǰ̨·½·¨£ºOnClientClick="return window.confirm('ÄãÈ·¶¨ÒªÉ¾³ýÂð£¿')"
ºǫ́·½·¨£ºbtnDelete.Attributes.Add("onclick", "return confirm('ÄúÈ·¶¨ÒªÉ¾³ýÂð£¿');");
2¡¢DataSetÖÐÈ¡Öµ£º
lblTitle.Text = ds.Tables[0].Rows[0]["Title"]. ......
ʲôÊÇLINQ?
LINQÊÇÓïÑÔ¼¯³É²éѯ(Language Integrated Query)µÄ¼ò³Æ£¬ÊÇVisual Studio 2008 ºÍ.NET Framework 3.5 °æÖÐÒ»Ïî,Í»ÆÆÐԵĴ´Ð£¬ËüÔÚ¶ÔÏóÁìÓòºÍÊý¾ÝÁìÓòÖ®¼ä¼ÜÆðÁËÒ»×ùÇÅÁº.
Ò»¸ö¼òµ¥LINQ²éѯ£º
&n ......
CookieΪ¿Í»§¶ËÐÅÏ¢´æ·Å¶ÔÏ󣬿ÉÒÔ°ÑÓû§µÄÐÅÏ¢±£´æÔÚÓû§±¾µØ£¬²»±Ø×ÜÊÇ·ÃÎÊ·þÎñÆ÷
ÓëSession²»Í¬£¬SessionΪÓû§È«¾Ö±äÁ¿£¬¶ÔÓÚ¸ÃÓû§µÄËùÓвÙ×÷¹ý³Ì¶¼ÓÐЧ¡£
//1¡£´´½¨Cookie¶ÔÏó
HttpCookie newCookie = new HttpCookie("User");
//2¡£CookieÖÐÌí¼ÓÐÅÏ¢ÏΪ¼üÖµ¶Ô£¬key/value
newCookie.Values.Add("Name" ......