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 = "ÉÏ´«³É¹¦!!!";
//ÏÔʾͼÆ
Ïà¹ØÎĵµ£º
//´´½¨
HttpCookie cookie = new HttpCookie("user","111");//´´½¨Cookie
cookie Expires = DateTime.Now.Add(15);//ÉèÖùýÆÚʱ¼ä
Response.Cookies.Add(cookie);//´æÈë¿Í»§¶Ë
ÎÒÃÇÈ¡³öCookieÖµÒ²ºÜ¼òµ¥
string value = Request.Cookies["user"].value;
ÓÐʱºòÎÒÃÇÏëÔÚÒ»¸öCookieÖд¢´æ¶à¸öÐÅÏ¢£¬ÄÇÒ ......
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯¡¡
¡¡
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ ......
¡¡¡¡Ê×Ïȼì²éWeb.configÎļþÀïÊÇ·ñÊÇÈçÏ´úÂ룺
¡¡¡¡´ò¿ªVS2005´´½¨ÐÂÏîÄ¿£¬Ñ¡ÔñASP.NET¡¡AJAXÏîÄ¿£¬È»ºó°Ñ¸ÃÏîÄ¿Web.configÎļþµÄÄÚÈÝÈ«²¿¸´ÖƵ½Ä㱨´íµÄWeb.configÎļþÀï¡£
¡¡¡¡Èç¹ûÕâ¸ö°ì·¨Î´Äܽâ¾ö°ì·¨Çë²é¿´¸ÃÏîÄ¿¸ùĿ¼µÄBinÎļþ¼ÐÄÚÊÇ·ñÓÐSystem.Web.Extensions.Design.dll¡¢System.Web.Extensions.dll¡¢A ......
1¡¢¸øɾ³ý°´Å¥Ìí¼ÓÊÇ·ñÈ·ÈÏÌáʾ£º
ǰ̨·½·¨£ºOnClientClick="return window.confirm('ÄãÈ·¶¨ÒªÉ¾³ýÂð£¿')"
ºǫ́·½·¨£ºbtnDelete.Attributes.Add("onclick", "return confirm('ÄúÈ·¶¨ÒªÉ¾³ýÂð£¿');");
2¡¢DataSetÖÐÈ¡Öµ£º
lblTitle.Text = ds.Tables[0].Rows[0]["Title"]. ......
²½Ö裺
£±.¡¡Ð½¨Ò»¸öWEB½â¾ö·½°¸Ãû³ÆΪHtmlStatic¡£
£².¡¡ÔÚÏîĿϽ¨Ò»¸öHtmlTemp.htmÆä´úÂëÈçÏ£º
¡¡¡¡¡¡<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head&g ......