Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

̽Ë÷Asp.netµÄPostback»úÖÆ

/* from: http://www.techmango.com/blog/article/DotNet/Explore_Asp_net_postback_mechanism.htm */
__doPostBack×÷ΪÔÚasp.netÖÐÒ»¸öºÜºËÐĺÜÖØÒªµÄ²¿·Ö,ÎÒÃÇÓбØÒªÉîÈëÁ˽âÒ»ÏÂ.
Æäʵ,__doPostBackÊÇÒ»¸öºÜ¼òµ¥µÄ½Å±¾º¯Êý.´úÂëÈçÏÂ:
//__doPostBack<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /><input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />function __doPostBack(eventTarget, eventArgument) {if (!theForm.onsubmit || (theForm.onsubmit() != false)) {theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;theForm.submit();}}
Ô­À´ÊÇÔÚsubmitÉÏ×öÎÄÕ°¡.microsoft³ÊÏÖ¸øÎÒÃǵľÍÊÇÕâÖÖ¾«ÇɵÄ˼ά!
ÎÒ¿´µ½,asp.netÏÖÔÚÒ³ÃæÉÏÌí¼ÓÁËÁ½¸öhidden input,ÕâÁ½¸öinput·Ö±ðÓÃÀ´´æ·Å´¥·¢postbackµÄcontrolµÄIDºÍ²ÎÊý.Õâ¾ÍÊÇÎÒÃǴ󲿷ÖÈËÈÏʶµ½µÄ:
__doPostBack(obj1,obj2)µÄµÚÒ»¸ö²ÎÊýÊǿؼþID,µÚ¶þ¸ö²ÎÊýÊÇpostbackµÄ²ÎÊý.È»ºó¾Í¿ÉÒÔÔÚºǫ́ÓÃRequest.Form["__EVENTTARGET"]ºÍ Request.Form["__EVENTARGUMENT"]È¡µÃ¿Ø¼þIDºÍ²ÎÊý.
²»¹ý,ÁíÍâҪעÒâµÄ¾ÍÊÇasp.netµÄwebcontrolsÖÐ,Button»òÆäËü***Button,ÈçImageButton¾ÍÌØÊâÁË,ËüÃDz»ÊÇÀûÓà __doPostBackÀ´ÊµÏÖpostbackµÄ.ΪʲôÕâÑù,¿ÉÄÜÒòΪButtonÔÚhtmlÖб¾À´¾ÍÊÇÓд¥·¢submitʼþµÄ¹¦ÄÜ°É.asp.net²»¹ýÊÇÒªÁîÔ­À´htmlÖÐһЩ²»ÄÜ´¥·¢submitµÄ¶«Î÷submit,²ÅŪ³öÁË__doPostBackÀ´ÊµÏÖ°É.
ËùÒÔÈç¹ûÊÇButtonµÄpostback,ÔÚºǫ́ÊDz»ÄÜÓÃRequest.Form["__EVENTTARGET"]ºÍRequest.Form["__EVENTARGUMENT"]È¡µÃ¿Ø¼þIDºÍ²ÎÊýµÄ.ÄÇô,ÔõôȡÄØ?¿´´úÂë:
//È¡Buttonforeach (string str in Request.Form){  Control c = Page.FindControl(str);  if (c is Button)  {    control = c;    break;  }}
ÉÏÊöд·¨¿ÉÒÔÔÚºǫ́ÕÒµ½Button.ÔÚButtonµÄÌá½»¹ý³ÌÖÐ,Button»á½«Button±¾ÉíµÄID×÷ΪRequest.FormµÄÒ»¸öKey£¬ËüµÄValueÊÇButtonµÄ TextÊôÐÔÖµ£¬»Ø´«¸ø·þÎñÆ÷.ËùÒÔ¿ÉÒÔÔÚºǫ́ѭ»·Form.KeysÈ¡µ½ËùÌá½»µÄButton,ÒÔÖ´ÐÐÏàÓ¦µÄº¯Êý.ImgButtonÒ²²î²»¶à,²»Í¬¾ÍÔÚÓÚ£¬Ëü²»ÊÇÓÃImageButtonµÄID×÷ΪRequest.FormµÄKey£¬ËüÊÇÓÃImageButtonµÄID¼ÓÉÏ.xºÍ.y×÷ΪKey£¬ÔÚ Request.FormÌí¼ÓÁ½ÉϼüÖµ¶Ô£¬ÕâÁ½¸ö¼üÖµÓ¦¸ÃÊǶÔÓ¦ImageButtonµÄͼƬ´


Ïà¹ØÎĵµ£º

asp.netÒ³ÃæʼþÖ´ÐÐ˳Ðò¼°¸÷ʼþ×÷ÓÃ

    protected void Page_Load(object sender, EventArgs e)
    {
    }
    #region OnPreInit µÚÒ»²½
    protected override void OnPreInit(EventArgs e)
    {
        //¼ì²é ......

ASP.NETÒ³Ãæ´«Öµ_µÚһƪ_¸ÅÊö


·½·¨
Êý¾ÝÁ¿
ÉúÃüÆÚ
×÷ÓÃÓò
λÖÃ
Application
ÈÎÒâ´óС
Õû¸öÓ¦ÓóÌÐò
ËùÓÐÓû§
·þÎñ¶Ë
Cache
ÈÎÒâ´óС
¸ù¾ÝÐèÒªÉ趨
ËùÓÐÓû§
·þÎñ¶Ë
Cookie
¼òµ¥Êý¾Ý
¸ù¾ÝÐèÒªÉ趨
µ¥¸öÓû§
¿Í»§¶Ë
Session
¼òµ¥Êý¾Ý
Óû§»î¶¯Ê±¼ä+ÑÓ³Ùʱ¼ä(20·ÖÖÓ)
µ¥¸öÓû§
·þÎñ¶Ë
Web.Config
¼«Éٸıä¼òµ¥Êý¾Ý
Ö±µ½¸Ä±äÅä ......

ASP.NETÒ³Ãæ´«Öµ_µÚ°Ëƪ_WebConfig

+++ ÐÞ¸ÄWebConfigÎļþ£º
<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="connStr" value="Data Source=ora11g;uid=scott;pwd=tiger;unicode=true"/>
  </appSettings>
  <connectionStrings>
    <ad ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ