重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

ASP.NET调用UpdatePanel的Update()方法实例

本篇内容介绍了“ASP.NET调用UpdatePanel的Update()方法实例”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

公司主营业务:成都做网站、网站制作、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联推出兖州免费做网站回馈大家。

ASP.NET中用编程的方法控制UpdatePanel的更新

UpdatePanel可以用来创建丰富的局部更新Web应用程序,它是ASP.NET 2.0 AJAX Extensions中很重要的一个控件。对于UpdatePanel,我们也可以使用编程的方法来控制它的更新,可以通过ScriptManager的RegisterAsyncPostBackControl()方法注册一个异步提交的控件,并且调用UpdatePanel的Update()方法来让它更新。再次用我在前面的文章中用到的一个无聊的时间更新例子来看一下,有时候我觉得例子过于复杂更加不好说明白所要讲的内容,如下代码所示,注意Button1并不包含在UpdatePanel中:

  1. <%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default
    .aspx.cs"Inherits="_Default"%> 

  2. <scriptrunatscriptrunat="server"> 

  3. voidButton1_Click(objectsender,EventArgse)  

  4. {  

  5. this.Label2.Text=DateTime.Now.ToString();  

  6. }  

  7. script> 

  8. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 

  9. <headrunatheadrunat="server"> 

  10. </strong>RefreshinganUpdatePanelProgrammatically<strong>title></strong> </p></li><li><p><strong>head></strong> </p></li><li><p><strong><body></strong> </p></li><li><p><strong><</strong>formid<strong>formid</strong>="form1"runat="server"<strong>></strong> </p></li><li><p><strong><</strong>asp:ScriptManagerID<strong>asp:ScriptManagerID</strong>="ScriptManager1<br/>"runat="server"<strong>/></strong> </p></li><li><p><strong><div></strong> </p></li><li><p><strong><</strong>asp:UpdatePanelID<strong>asp:UpdatePanelID</strong>="UpdatePanel1"runat=<br/>"server"UpdateMode="Conditional"<strong>></strong> </p></li><li><p><strong><ContentTemplate></strong> </p></li><li><p><strong><</strong>asp:LabelID<strong>asp:LabelID</strong>="Label1"runat="server"Text=<br/>"更新时间:"<strong>>asp:Label></strong> </p></li><li><p><strong><</strong>asp:LabelID<strong>asp:LabelID</strong>="Label2"runat="server"Text=<br/>"Label"ForeColor="Red"<strong>>asp:Label><br/><br/></strong> </p></li><li><p><strong>ContentTemplate></strong> </p></li><li><p><strong>asp:UpdatePanel></strong> </p></li><li><p><strong><</strong>asp:ButtonID<strong>asp:ButtonID</strong>="Button1"runat="server"Text=<br/>"Button"OnClick="Button1_Click"<strong>/></strong> </p></li><li><p><strong>div></strong> </p></li><li><p><strong>form></strong> </p></li><li><p><strong>body></strong> </p></li><li><p><strong>html></strong> </p></li></ol></pre><p>再次修改上面的例子,使用ScriptManager的RegisterAsyncPostBackControl()注册Button1为一个异步提交控件,并且调用UpdatePanel的Update()方法:</p><pre><ol><li><p><strong><</strong>%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"<br/>Inherits="_Default"%<strong>></strong> </p></li><li><p><strong><</strong>scriptrunat<strong>scriptrunat</strong>="server"<strong>></strong> </p></li><li><p>voidPage_Load(objectsender,EventArgse)  </p></li><li><p>{  </p></li><li><p>ScriptManager1.RegisterAsyncPostBackControl(Button1);  </p></li><li><p>}  </p></li><li><p>voidButton1_Click(objectsender,EventArgse)  </p></li><li><p>{  </p></li><li><p>this.Label2.Text=DateTime.Now.ToString();  </p></li><li><p>this.UpdatePanel1.Update();  </p></li><li><p>}  </p></li><li><p><strong>script></strong> </p></li><li><p><strong><</strong>htmlxmlns<strong>htmlxmlns</strong>="http://www.w3.org/1999/xhtml"<strong>></strong> </p></li><li><p><strong><</strong>headrunat<strong>headrunat</strong>="server"<strong>></strong> </p></li><li><p><strong><title></strong>RefreshinganUpdatePanelProgrammatically<strong>title></strong> </p></li><li><p><strong>head></strong> </p></li><li><p><strong><body></strong> </p></li><li><p><strong><</strong>formid<strong>formid</strong>="form1"runat="server"<strong>></strong> </p></li><li><p><strong><</strong>asp:ScriptManagerID<strong>asp:ScriptManagerID</strong>="ScriptManager1"runat="server"<strong>/></strong> </p></li><li><p><strong><div></strong> </p></li><li><p><strong><</strong>asp:UpdatePanelID<strong>asp:UpdatePanelID</strong>="UpdatePanel1"runat=<br/>"server"UpdateMode="Conditional"<strong>></strong> </p></li><li><p><strong><ContentTemplate></strong> </p></li><li><p><strong><</strong>asp:LabelID<strong>asp:LabelID</strong>="Label1"runat="server"Text="更新时间:"<strong>>asp:Label></strong> </p></li><li><p><strong><</strong>asp:LabelID<strong>asp:LabelID</strong>="Label2"runat="server"Text="Label"ForeColor<br/>="Red"<strong>>asp:Label><br/><br/></strong> </p></li><li><p> </p></li><li><p><strong>ContentTemplate></strong> </p></li><li><p><strong>asp:UpdatePanel></strong> </p></li><li><p><strong><</strong>asp:ButtonID<strong>asp:ButtonID</strong>="Button1"runat="server"Text=<br/>"Button"OnClick="Button1_Click"<strong>/></strong> </p></li><li><p><strong>div></strong> </p></li><li><p><strong>form></strong> </p></li><li><p><strong>body></strong> </p></li><li><p><strong>html></strong> </p></li></ol></pre><p>“ASP.NET调用UpdatePanel的Update()方法实例”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!</p> <br> 当前文章:ASP.NET调用UpdatePanel的Update()方法实例 <br> 网页URL:<a href="http://cqcxhl.com/article/isjsho.html">http://cqcxhl.com/article/isjsho.html</a> </div> </div> <div class="other"> <h3>其他资讯</h3> <ul> <li> <a href="/article/dcgcgej.html">java编程思想代码包 java编程思想源码下载</a> </li><li> <a href="/article/dcgcged.html">sap系统收发货的简单介绍</a> </li><li> <a href="/article/dcgcgii.html">腾讯云境外服务器更换ip 腾讯云国外服务器</a> </li><li> <a href="/article/dcgcidc.html">阿里云服务器自动掉线 阿里云服务器不稳定</a> </li><li> <a href="/article/dcgcgoj.html">帝国cms调用字段 帝国cms sql</a> </li> </ul> </div> </div> <div class="footer"> <div class="footer_content"> <div class="footer_content_top clear"> <div class="content_top_share fl"> <div><img src="/Public/Home/img/logo.png"></div> <div class="top_share_content"> <dd>分享至:</dd> <dt class="bdsharebuttonbox clear" id="share"> <a href="#" class="bds_tsina iconfont fl" data-cmd="tsina" title="分享到新浪微博"></a> <a href="#" class="bds_sqq iconfont fl" data-cmd="sqq" title="分享到QQ好友"></a> <a href="#" class="bds_weixin iconfont fl" data-cmd="weixin" title="分享到微信"></a> <a href="#" class="bds_weixin iconfont fl" data-cmd="tieba" title="分享到贴吧"></a> </dt> <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script> </div> </div> <div class="content_top_left fl clear"> <div class="top_left_list fl"> <dd><a href="/about/">关于我们</a></dd> <dt> <a href="/about/#gsjj">公司简介</a> <a href="/about/#fzlc">发展历程</a> </dt> </div> <div class="top_left_list fl"> <dd><a href="/service/">服务项目</a></dd> <dt> <a href="/service/">高端网站建设</a> <a href="/miniprogram/">小程序开发</a> <a href="/service/app.html">APP开发</a> <a href="/service/yingxiao.html">网络营销</a> </dt> </div> <div class="top_left_list fl"> <dd><a href="/jianzhan/">建站知识</a></dd> <dt> <a href="/jianzhan/2.html">网站建设</a> <a href="/jianzhan/3.html">网站设计</a> <a href="/jianzhan/4.html">网站制作</a> <a href="/jianzhan/5.html">小程序</a> </dt> </div> <div class="top_left_list fl"> <dd><a href="/contact/">联系我们</a></dd> <dt> <a href="/contact/#lxwm">公司地址</a> <a href="/contact/#rczp">人才招聘</a> </dt> </div> </div> <div class="content_top_right addressR fr"> <div class="top_right_title addressf_title"> <a href="javascript:;" class="on">成都</a> <a href="javascript:;">重庆</a> </div> <div class="top_right_content addressf"> <div class="right_content_li on"> <div class="right_content_list clear"> <dd class="fl iconfont"></dd> <dt class="fl">电话:028-86922220</dt> </div> <div class="right_content_list clear"> <dd class="fl iconfont"></dd> <dt class="fl">地址:成都市太升南路288号锦天国际A幢1002号</dt> </div> </div> <div class="right_content_li"> <div class="right_content_list clear"> <dd class="fl iconfont"></dd> <dt class="fl">电话:028-86922220</dt> </div> <div class="right_content_list clear"> <dd class="fl iconfont"></dd> <dt class="fl">地址:重庆市南岸区弹子石腾龙大道58号2栋21-6</dt> </div> </div> </div> </div> </div> </div> <div class="footer_content_copyright clear">版权所有:成都创新互联科技有限公司重庆分公司 <a href="http://beian.miit.gov.cn/" rel="nofollow" target="_blank">渝ICP备2021005571号-4</a> </div> </div> <!--浮窗--> <div class="FloatingWindow clear"> <a href="tencent://message/?uin=1683211881&Site=&Menu=yes" class="FloatingWindow_list fr"> <div class="FloatingWindow_list_title"> <dd class="iconfont"></dd> <dt><span>在线</span>咨询</dt> </div> </a> <a href="javascript:;" class="FloatingWindow_list fr"> <div class="FloatingWindow_list_title"> <dd class="iconfont"></dd> <dt>服务热线</dt> </div> <div class="FloatingWindow_list_down fadeInRight animated">服务热线:028-86922220</div> </a> <a href="javascript:;" class="FloatingWindow_list fr STop"> <div class="FloatingWindow_list_title"> <dd class="iconfont"></dd> <dt>TOP</dt> </div> </a> </div> <script src="/Public/Home/js/jquery-1.8.3.min.js"></script> <script src="/Public/Home/js/comm.js"></script> <script src="/Public/Home/js/wow.js"></script> <script src="/Public/Home/js/common.js"></script> </body> </html> <script> $(".con img").each(function(){ var src = $(this).attr("src"); //获取图片地址 var str=new RegExp("http"); var result=str.test(src); if(result==false){ var url = "https://www.cdcxhl.com"+src; //绝对路径 $(this).attr("src",url); } }); </script>