资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

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> 本文路径:<a href="http://cdkjz.cn/article/isjsho.html">http://cdkjz.cn/article/isjsho.html</a> </div> <div class="g-return-wrapper clearfix"> <a href="http://www.cdkjz.cn/" class="home">返回首页</a> <a href="http://www.cdkjz.cn/news/" class="column">了解更多建站资讯</a> </div> </div> </div> <div class="full-related-news"> <h3 class="related-title">相关资讯</h3> <div class="related-news weblg"> <ul class="clearfix"> <li> <a href="/article/epeed.html"> <h2 class="title">区块链的概念是什么-创新互联</h2> </a> </li><li> <a href="/article/epeig.html"> <h2 class="title">jquery中click事件和onclick事件有什么区别-创新互联</h2> </a> </li><li> <a href="/article/epeds.html"> <h2 class="title">基于javaServlet编码/异常处理(详解)-创新互联</h2> </a> </li><li> <a href="/article/epeep.html"> <h2 class="title">ASP.NETEval如何进行数据绑定-创新互联</h2> </a> </li><li> <a href="/article/epeee.html"> <h2 class="title">SQLServer中怎么实现备份和灾难恢复-创新互联</h2> </a> </li><li> <a href="/article/epedg.html"> <h2 class="title">python怎样重命名文件-创新互联</h2> </a> </li><li> <a href="/article/epeii.html"> <h2 class="title">在Tomcat中部署war和warexploded的区别是什么-创新互联</h2> </a> </li><li> <a href="/article/epeoo.html"> <h2 class="title">iOS系统的底层通知框架库示例详解-创新互联</h2> </a> </li> </ul> </div> </div> <div class="full-icontact-cover m-ft-contact"> <div class="weblg"> <div class="clearfix content"> <div class="motto"> 多年建站经验 </div> <div class="info"> <h3>多一份参考,总有益处</h3> <h2> 联系快上网,免费获得专属《策划方案》及报价</h2> <div class="msg"> <p>咨询相关问题或预约面谈,可以通过以下方式与我们联系</p> <h4> 大客户专线   成都:<a href="tel:+13518219792" rel="nofollow">13518219792</a>   座机:<a href="tel:02886922220" rel="nofollow">028-86922220</a> </h4> </div> </div> </div> <div class="btns clearfix"> <a href="https://wpa.qq.com/msgrd?v=3&uin=631063699&site=qq&menu=yes" target="_blank" rel="nofollow" class="oline">在线咨询</a> <a href="javascript:;" class="edit" rel="nofollow">提交需求</a> </div> </div> </div> <div class="footer-content"> <div class="weblg clearfix"> <div class="friend-links"> <h6 class="clearfix"> <span class="tilte">友情链接</span> <a class="exchagne" href="http://wpa.qq.com/msgrd?v=3&uin=631063699&site=qq&menu=yes">交换友情链接</a> </h6> <div class="link-list clearfix"> <div class="link-slider"> <a href="http://www.jinhuajc.com/" title="成都橡塑保温板" target="_blank">成都橡塑保温板</a><a href="http://m.cdcxhl.cn/dingzhi/ " title="定制网站开发" target="_blank">定制网站开发</a><a href="http://www.swwzsj.com/" title="汕尾凯敏网站" target="_blank">汕尾凯敏网站</a><a href="http://www.cdhuace.com/fuwu.html" title="名片设计" target="_blank">名片设计</a><a href="https://www.cdxwcx.com/jifang/guanghua.html" title="成都光华机房" target="_blank">成都光华机房</a><a href="http://chengdu.cdcxhl.cn/dingzhi/ " title="高端定制网站设计" target="_blank">高端定制网站设计</a><a href="https://www.scvps.cn/" title="注册域名" target="_blank">注册域名</a><a href="http://www.cdymzj.com/" title="云主机" target="_blank">云主机</a><a href="http://www.cdkjz.cn/fangan/store/" title="电商网站建设方案" target="_blank">电商网站建设方案</a><a href="http://www.cxjianzhan.com/" title="成都网站制作" target="_blank">成都网站制作</a> </div> </div> </div> </div> <div class="full-foot-bottom"> <div class="weblg clearfix"> <p>成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询<a href="tel:028-86922220">028-86922220</a></p> <p> 成都快上网科技有限公司-四川网站建设设计公司 | <a href="http://www.miitbeian.gov.cn/" target="_blank" rel="nofollow">蜀ICP备19037934号</a> Copyright 2020,ALL Rights Reserved cdkjz.cn | <a href="http://www.cdkjz.cn/" target="_blank">成都网站建设</a> | © Copyright 2020版权所有.</p> <p>专家团队为您提供<a href="http://www.cdkjz.cn/" target="_blank">成都网站建设</a>,<a href="http://www.cdkjz.cn/" target="_blank">成都网站设计</a>,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | <a href="###">网站建设地图</a></p> </div> </div> </div> <script type="text/javascript" src="../js/idangerous.swiper.min.js"></script> <script type="text/javascript" src="../js/wow.min.js"></script> <script type="text/javascript" src="../js/jquery.mousewheel.min.js"></script> <script type="text/javascript" src="../js/jquery.placeholder.min.js"></script> <script type="text/javascript" src="../js/layout.js"></script> </body> </html> <script> $(".singlepage 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); } }); window.onload=function(){ document.oncontextmenu=function(){ return false; } } </script>