ASP.NET ¼¼ÇÉƪ
Asp.NetÖм¸ÖÖÏàËƵıê¼Ç·ûºÅ: < %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Container.DataItem("tit") %>
< %= %>: ÔÚ³ÌÐòÖ´ÐÐʱ±»µ÷Ó㬿ÉÒÔÏÔʾºǫ́±äÁ¿Öµ
Èç:
*.aspxÖУº < %= aaa %>
*.csÖÐ: protected string aaa="ÐÕÃû";
< % %>: ÄÚÁª´úÂë¿éÀïÃæ¿ÉÒÔÔÚÒ³ÃæÎļþ*.aspx»ò*.ascxÎļþÀïÃæǶÈëºǫ́´úÂë
Èç:
< %
for(int i=0;i<100;i++)
{
Reaponse.Write(i.ToString());
}
%>
< %@ %>ÊÇÔÚ*.aspxÒ³Ãæǰ̨´úÂëµ¼ÈëÃüÃû¿Õ¼ä,
Èç:
< %@ Import namespace="System.Data"%>
2.¿Ø¼þ½ÓÊÕÄÄЩÀàÐÍÊý¾Ý?
´ð:½ÓÊÕBindµÄ¿Ø¼þ£¬Ò»°ãÓÐDropDownList,DataList,DataGrid,ListBoxÕâЩ¼¯ºÏÐÔÖʵĿؼþ£¬¶ø±»À¦°ó
µÄÖ÷ÒªÊÇArrayList(Êý×é),Hashtable(¹þÏ¡±í),DataView(Êý¾ÝÊÓͼ),DataReaderÕâËĸö£¬ÒÔºóÎÒÃǾͿÉÒÔ
¶ÔºÅÈë×ù£¬²»»á³öÏÖDataTable±»À¦°óµÄ´íÎóÁË£º£©
3.DataBind,»ñµÃµÄÊý¾Ý£¬ÏµÍ³»á½«ÆäĬÈÏΪString,ÔõÑùת»¯ÎªÆäËüµÄÀàÐÍ?
DataBinder.Eval(Container.DataItem,"ת»»µÄÀàÐÍ","¸ñʽ")
×îºóÒ»¸ö"¸ñʽ"ÊÇ¿ÉÑ¡µÄ£¬Ò»°ã²»ÓÃÈ¥¹ÜËû£¬Container.DataItemÊÇÀ¦°óµÄÊý¾ÝÏî,"ת»»ÀàÐÍ"Ö¸µÄÊÇ Integer,String,BooleanÕâÒ»ÀණÎ÷.
4.Ö÷ÒªÃüÃû¿Õ¼ä:
< % @ Import Namespace="System.Data" %> ´¦ÀíÊý¾ÝʱÓõ½
< % @ Import Namespace="System.Data.ADO" % > ʹÓÃADO.net ; ʱÓõ½
< % @ Import Namespace="System.Data.SQL" %> SQL Server Êý¾Ý¿âרÓÃ
< % @ Import Namespace="System.Data.XML" %> ²»Óÿ´´¦ÀíXMLÓõ½
< % @ Import Namespace="System.IO" %> ´¦ÀíÎļþʱÓõ½
< % @ Import Namespace="System.Web.Util" %> ·¢Óʼþʱ´ó¼Ò»áÓõ½
< % @ Import Namespace="System.Text" %> Îı¾±àÂëʱÓõ½
5.Connections(SQLConection »òÕß ADOConnection)µÄ³£ÓÃÊôÐԺͷ½·¨:
| ConnectionString È¡µÃ»òÉèÖÃÁ¬½áÊý¾Ý¿âµÄÓï¾ä
| ConnectionTimeout È¡µÃ»òÉèÖÃÁ¬½áÊý¾Ý¿âµÄ×ʱ¼ä£¬Ò²ÊǾͳ¬Ê±Ê±¼ä
| DataBase È¡µÃ»òÉèÖÃÔÚÊý¾Ý¿â·þÎñÆ÷ÉÏÒª´ò¿ªµÄÊý¾Ý¿âÃû
| DataSource È
Ïà¹ØÎĵµ£º
ÔÚÐí¶àÓ¦ÓóÌÐòÖУ¬ÐèÒª´æ´¢²¢Ê¹ÓöÔÓû§Î¨Ò»µÄÐÅÏ¢¡£Óû§·ÃÎÊÕ¾µãʱ£¬Äú¿ÉÒÔʹÓÃÒÑ´æ´¢µÄÐÅÏ¢ÏòÓû§ÏÔʾ Web Ó¦ÓóÌÐòµÄ¸öÐÔ»¯°æ±¾¡£¸öÐÔ»¯Ó¦ÓóÌÐòÐèÒª´óÁ¿µÄÔªËØ£º±ØÐëʹÓÃΨһµÄÓû§±êʶ·û´æ´¢ÐÅÏ¢£¬Äܹ»ÔÚÓû§ÔٴηÃÎÊʱʶ±ðÓû§£¬È»ºó¸ù¾ÝÐèÒª»ñÈ¡Óû§ÐÅÏ¢¡£ÈôÒª¼ò»¯Ó¦ÓóÌÐò£¬¿ÉÒÔ ......
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕʱÊÕ»ØÁ¬½ ......
¶ÔÓÚasp.net,ĬÈÏÖ»ÔÊÐíÉÏ´«2MÎļþ,Ôö¼ÓÈçÏÂÅäÖÃ,Ò»°ã¿ÉÒÔ×Ô¶¨Òå×î´óÎļþ´óС.
<httpRuntime executionTimeout="300" maxRequestLength="40960" useFullyQualifiedRedirectUrl="false"/>
ÎÒÃÇÔÚÉÏ´«´óÎļþʱ¶¼Óöµ½¹ýÕâÑù»òÄÇÑùµÄÎÊÌâ¡£ÉèÖúܴóµÄmaxRequestLengthÖµ²¢²»ÄÜÍê ......
using System;
using System.Collections.Specialized;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebC ......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LeftMenu.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xht ......