ÇåÇå³þ³þasp.net ( Èý ) £ºViewState
ViewState¸ÅÊö
Ò³ÃæÔÚ³õʼ»¯µÄʱºò£¬asp.net»áÔÚÒ³ÃæÄÚ½¨ViewStateÊôÐÔ£¬ÎÒÃÇ¿ÉÒÔ½«ÐèÒª±£´æµÄÊý¾Ý·Åµ½ÊÓͼ״̬µÄ¼¯ºÏÖУ¬ÒÔ´ïµ½ÔÚÒ³Ãæ»Ø·¢µÄʱºò±£´æÊý¾ÝµÄÄ¿µÄ¡£
ʹÓÃViewStateÒÔÇ°£¬ÐèҪעÒâÒÔÏÂÄÚÈÝ£º
1.ViewStateÒÀÀµÓÚ×ֵ伯ºÏ¡£
2.ViewStateÖеÄÿһÏîͨ¹ýΨһµÄ×Ö·û´®Ãû×Ö½øÐÐË÷Òý¡£
ÎÒÃÇÔÚ¸øÊÓͼ¼¯ºÏµÄij¸öË÷ÒýÏֵµÄʱºò£¬Èç¹ûÊÓͼ¼¯ºÏÖдæÔÚ¸ÃË÷ÒýÏÔò¸³Öµ£»Èç¹ûûÓУ¬Ôò¸ÄË÷ÒýÏ»á±»×Ô¶¯Ìí¼Ó²¢¸³Öµ¡£
ÔÚ³¢ÊÔ´ÓÊÓͼ¼¯ºÏÖÐÈ¡³öij¸öË÷ÒýÏîµÄÖµµÄʱºò£¬Èç¹ûÊÓͼ¼¯ºÏÖв»´æÔÚ´ËË÷ÒýÏîµÄʱºò£¬½«»áÅ׳öÒì³£¡£
Òò´ËÎÒÃÇÔÚÈ¡ÖµµÄʱºò£¬Í¨³£»á¼Ó¸öÅжϡ£
ÀýÈ磺
´úÂë
if (ViewState["test"] != null)
{
int test = (int)ViewState["test"];
}
3.ViewState¿ÉÒÔ±£´æ¼òµ¥Êý¾ÝÀàÐͺÍ×Ô¶¨Òå¶ÔÏó¡£
4.ÈκÎͨ¹ýË÷Òý×Ö·û´®´ÓViewStateÖÐÈ¡³öÀ´µÄÊý¾Ý¶¼ÊÇObjectÀàÐÍ£¬ÎÒÃÇÐèÒªÏÔʽµÄ½«Æäת»»³ÉÐèÒªµÄÀàÐÍ£¬ÈçÉÏÀý¡£
ʹÓÃViewStateµÄÒ»¸öÀý×Ó
html
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br/>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br/>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br/>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br/>
<asp:Button ID="Button1" runat="server" Text="Save" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Restore" onclick="Button2_Click" />
<asp:Button ID="Button3" runat="server" Text="SaveWithDictionary" onclick="Button3_Click" />
Ïà¹ØÎĵµ£º
1. PreInit()ÔÚÕâ¸öÒ³Ã漶µÄʼþÖУ¬ËùÓÐÔÚÉè¼Æʱ´´½¨µÄ¿Ø¼þ¶¼½«±»ÓÃĬÈÏÖµ×ö³õʼ»¯¡£ÀýÈ磬Èç¹ûÄãÓÐÒ»¸öTextÊôÐÔֵΪ"Hello"µÄTextBox¿Ø¼þ£¬Ôò´ËʱÕâ¸öÊôÐÔ±»ÉèÖá£ÎÒÃÇÒ²¿ÉÒÔÔÚÕâÀﶯ̬µÄ´´½¨¿Ø¼þ¡£Õâ¸öʼþ½ö½ö·¢ÉúÔÚÒ³¼¶±ðµÄÀàÖУ¬Óû§¿Ø¼þºÍĸ°æҳûÓÐÕâ¸öʼþ¡£ÏÂÃæµÄ´úÂëʾÀýÁËÈçºÎÖØдÕâ¸ö·½·¨ÒÔÔö¼ÓÄãµÄ×Ô¶¨Òå´úÂë ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
StartClientCaching();
......
ÔÎijö´¦£ºhttp://www.cnblogs.com/raymond19840709/archive/2007/09/11/890045.html
×÷Õߣº´ó¿Ú×Ð
µÚÒ»£º
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToSt ......
ASP.NET IIS ×¢²á¹¤¾ß (Aspnet_regiis.exe)
ÔÚһ̨¼ÆËã»úÉϲ¢ÐÐÖ´Ðжà¸ö .NET Framework °æ±¾Ê±£¬Ó³Éäµ½ ASP.NET Ó¦ÓóÌÐòµÄ ASP.NET ISAPI °æ±¾¾ö¶¨Á˸ÃÓ¦ÓóÌÐòËùʹÓõĹ«¹²ÓïÑÔÔËÐпâ (CLR) °æ±¾¡£Ê¹Óà ASP.NET IIS ×¢²á¹¤¾ß (Aspnet_regiis.exe)£¬¹ÜÀíÔ±»ò°²×°³ÌÐò¿ÉÒÔ·½±ãµØ¸üРASP.NET Ó¦ÓóÌÐòµÄ½Å±¾Ó³É䣬ʹÆäÖ¸Ï ......
Ò»£®Code Behind¼ò½é
¡¡¡¡Code Behind¾ÍÊÇËùνµÄ´úÂë·ÖÀ룬×Ô´ÓMicrosoft¹«Ë¾ÍƳöÁËASP.NETÒÔºó£¬Code
Behind¾ÍÊÇÒ»¸öÈÈÃŵĻ°Ìâ¡£ÔÚÒ»°ãµÄASP.NETÎļþÖУ¬Code
BehindÖ÷ÒªÊÇÓöþ¸öÎļþÀ´´´½¨Ò»¸öASP.NETµÄÒ³Ã棬ÆäÖÐÒ»¸öÊÇÉè¼ÆÎļþ£¬Ò»°ãÒÔ.aspx»òÕß.ascx×öΪÀ©Õ¹Ãû£¬¶øÁíÍâÒ»¸öÊdzÌÐò´úÂëÎÄ
¼þ£¬Ò»°ãÒÔ.vb»òÕß.cs×öΪ ......