ASP.NET ÊÓͼ״̬
Web ÊÇ»ùÓÚÎÞ״̬µÄhttpÐÒ飬ASP.NET ΪÁ˱£Ö¤¿Ø¼þÔÚÒ³Ãæ´«Ë͵½·þÎñÆ÷£¬ÔÙ´Ó·þÎñÆ÷·¢»Øµ½Ò³ÃæµÄʱ±£³Ö֮ǰµÄ״̬¡£
´úÂë×¼±¸£º
ÔÚaspxÒ³ÃæÉÏÌí¼ÓÒ»¸ölistbox¿Ø¼þ£¬ºÍÒ»¸öbutton·þÎñÆ÷¿Ø¼þ£º
<
asp:ListBox runat
=
"
server
"
ID
=
"
lbViewState
"
></
asp:ListBox
>
<
asp:Button runat
=
"
server
"
ID
=
"
Button1
"
Text
=
"
Submit
"
/>
ÔÚºǫ́csÎļþÉϼÓÉÏ´úÂëÈçÏ£º
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(
!
Page.IspostBack)
{
this
.lbViewState.Items.Add(
new
ListItem(
"
1
"
));
this
.lbViewState.Items.Add(
new
ListItem(
"
2
"
));
this
.lbViewState.Items.Add(
new
ListItem(
"
3
"
));
}
}
ÔÚµÚÒ»´ÎÇëÇóµÄʱºò¸ølistbox×Ô¶¯µÄÌí¼ÓÉÏÈý¸öÏî¡£
ÔËÐнá¹û£º
µÚÒ»´ÎÔËÐеÄʱºò£º
µ±µã»÷°´Å¥submitʱºò£º
Á½´Î½á¹ûÒ»Ñù£¬ÕâÊÇÒòΪÔÚÊÓͼ״̬±£´æÁËÇëÇó֮ǰlistboxµÄÄÚÈÝ¡£
Èç¹û°Ñ¿Ø¼þµÄÊÔͼ״̬ȡÏû£¬Ò²¾ÍÊǸæËßASP.NET²»ÒªÎª´Ë¿Ø¼þ±£´æÊÔͼ״̬£¬ÄÇô¾ÍÔÚ¶¨Òå¿Ø¼þµÄʱºòÌí¼ÓÊôÐÔEnableViewState£¬²¢ÉèÖÃΪfalse¡£¼´£ºEnableViewState="false"¡£
<
asp:ListBox runat
=
"
server
"
ID
=
"
lbViewState
"
EnableViewState
=
"
false
"
></
asp:ListBox
>
<
asp:Button runat
=
"
server
"
ID
=
"
Button1
"
Text
=
"
Submit
"
/>
ÔËÐнá¹û£º
µ±µÚÒ»´ÎÇëÇóµÄʱºò£º
µã»÷submint°´Å
Ïà¹ØÎĵµ£º
Ç°ÑÔ£º
Ç°¼¸ÈÕ£¬ÎÞÄÎÓÃJSÅжϿؼþµÄÓÐЧÐÔ£¬·¢ÏÖµÄÈ·ÊÇÒ»¼þ·ÑÁ¦¡¢·ÑÉñµÄÊÂÇ飡ÌرðÊÇÕë¶ÔÓʼþ¸ñʽ¡¢ÓÊÕþ±àÂëµÈµÄ¹ØÓÚÕýÔò±í´ïʽµÄJSÑéÖ¤£¨ÆäÖÐÉæ¼°ÕýÔò±í´ïʽµÄ±È½ÏµÈ£¬½Ï·³~£©¡£Æäʵ¶ÔÓÚÕâЩ³£ÓõĿؼþÓÐЧÐÔÑéÖ¤£¬ÔÚAsp.NetÖÐÓе¥¶ÀµÄÑéÖ¤¿Ø¼þ¿É¹©Ê¹Óá£ËûÃÇ¿ÉÒÔÂú×ãÒ»°ãµÄ£¬ÖîÈç·Ç¿Õ£¬·¶Î§¡¢±È½ÏµÈµÄÑé ......
ÎÒÏë×öÒ»¸ö¶àÖ¸±ê¶¯Ì¬²éѯ£¬ÇëÎÊÄÄλÐÖµÜ×ö¹ý£¬°ï¸ö棡¾ßÌåÒªÇóÊÇ:ÎÒ¿ÉÒÔËæÒâÑ¡ÔñÊý¾Ý¿â±íÖеÄÈκÎÒ»¸ö»ò¶à¸ö×ֶΣ¬È»ºó°ÑËûÃDzéѯ³öÀ´£¡ÎÒ»á×öµ¥Ö¸±í²éѯµÄ£¬µ«ÏÖÔÚ¹¦ÄÜÒªÒªÇó¶àÖ¸±ê¶¯Ì¬²éѯ£¡»áµÄ°ï¸öæ°¡@£¡¸Ðл֮ÖÁ£¡
ÀýÈçÎÒÏë²éÊý¾Ý¿â±íÖÐµÄ Óû§±àºÅ ÐÕÃû »òÕßÓû§±àºÅ ÐÕÃû Ê¡·Ý ÊÕÈë ²¢°Ñ¶ÔÓ¦µ ......
Asp.netÒ³ÃæÂÒÂëµÚÒ»ÖÖ½â¾ö·½°¸£º
ÔÚweb.configÖУº
<globalization requestEncoding="gb2312" responseEncoding="gb2312" />
Asp.netÒ³ÃæÂÒÂëµÚ¶þÖÖ½â¾ö·½°¸£º
<META http-equiv="content-type" content="text/html; charset=gb2312">
Asp.netÒ³ÃæÂÒÂëµÚÈýÖÖ½â¾ö·½°¸£º
ÏÂÔØÎļþʱָ¶¨ÎļþÃû£¬ÖÐÎĵÄÎÄ ......
×î½üÔÚsina¿´nbaµÄÎÄ×ÖÖ±²¥µÄʱºò£¬¶ÔÍøÕ¾ÓÒϽǵÄÄÇÒ»¸öÁÄÌì´°¿Ú²úÉúÐËȤ£¬¾Í¾ö¶¨×Ô¼ºÒ²×öÒ»¸ö¡£
ÉÏÍø²é²é×ÊÁÏ£¬ÕâÑùµÄÁÄÌìÊÒÎ޷ǾÍÊÇÓû§ÊäÈëÊý¾Ý´«µ½·þÎñÆ÷±£´æ£¬È»ºóÓû§Ò³ÃæÔÙʵʱµØ´ÓÊý¾Ý¿âÈ¡³öÊý¾Ý£¬ÏÔʾÔÚÒ³ÃæÉÏ£¬¼´¿ÉÍê³ÉÒ»´ÎÁÄÌì²Ù×÷¡£
Ê×ÏÈÎÒ¶¨ÒåÁËÒ»¸öxmlÎļþ£¬ÓÃÓÚ±£´æÓû§ ......