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°´Å
Ïà¹ØÎĵµ£º
C#´úÂëÓëjavaScriptº¯ÊýµÄÏ໥µ÷ÓÃ
ÎÊ£º
1.ÈçºÎÔÚJavaScript·ÃÎÊC#º¯Êý?
2.ÈçºÎÔÚJavaScript·ÃÎÊC#±äÁ¿?
3.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptµÄÒÑÓбäÁ¿?
4.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptº¯Êý?
ÎÊÌâ1´ð°¸ÈçÏ£º
javaScriptº¯ÊýÖÐÖ´ÐÐC#´úÂëÖеĺ¯Êý£º
·½·¨Ò»£º1¡¢Ê×ÏȽ¨Á¢Ò»¸ö°´Å¥£¬ÔÚºǫ́½«µ÷Óûò´¦ÀíµÄÄÚÈÝдÈëbutton_clickÖÐ ......
¡¾Õª Òª¡¿ ±¾ÎÄ»ùÓÚASP.NET 2.0µÄÔ´´úÂ룬¶ÔASP.NET 2.0ÔËÐÐʱ½øÐÐÁ˼òÒªµÄ·ÖÎö£¬Ï£ÍûÄÜ°ïÖúÄãÀí½âASP.NET 2.0ÖÐÇëÇó´¦Àí¹ý³Ì¼°Ò³Ãæ±àÒëÄ£ÐÍ¡£
¡¡¡¡Ö÷ÒªÀࣺ
¡¡¡¡System.Web.HttpRuntime
¡¡¡¡System.Web.HttpApplicationFactory
¡¡¡¡System.Web.HttpApplication
¡¡¡¡System.Web.Compilation.BuildManager
¡¡¡¡Syst ......
protected void Button3_Click(object sender, EventArgs e)
{
//¶¨Òå±äÁ¿,ÅжÏÊÇ·ñÓÐͼƬÉÏ´«
bool fileIsValid = false;
//Èç¹ûÓÐͼƬÉÏ´«,ÅжÏÆä¸ñʽ
&nbs ......
1¡¢Ö±½ÓÔÚǰ̨µ÷Óà javascript º¯Êý
ºÜ¼òµ¥,ÔÚ head ÔªËØÖ®¼ä¼ÓÈë script ÔªËØ,½« type ÔªËØÉèÖÃΪ " text/javascript "
Èç:
¸´ÖÆ´úÂë ´úÂëÈçÏÂ:
<head runat="server">
<script type="text/javascript" >
function ShowName(str)
{
alert("ÄúµÄÃû×ÖΪ:("+s ......