RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
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://scyingshan.cn/article/isjsho.html">http://scyingshan.cn/article/isjsho.html</a> </div> <div class="hot_new"> <div class="page_title clearfix"> <h3>其他资讯</h3> </div> <div class="news_list clearfix"> <ul> <li> <a href="/article/dsedhoj.html">jquery下拉树,下拉树是怎么实现的</a> </li><li> <a href="/article/dsedhdc.html">python定义函数代码,python函数的定义</a> </li><li> <a href="/article/dsedhog.html">JavaScript火,javascript的发展</a> </li><li> <a href="/article/dsedpgh.html">鸿蒙手机开发教程视频,鸿蒙 开发教程</a> </li><li> <a href="/article/dsedphs.html">函数水仙花数c语言程序,水仙花数c语言程序函数做法</a> </li> </ul> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <!-- 底部信息 --> <div class="footer wow fadeInUp"> <div class="rowFluid"> <div class="span12"> <div class="container"> <div class="footer_content"> <div class="span4 col-xm-12"> <div class="footer_list"> <div class="span6"> <div class="bottom_logo"><img src="/Public/Home/images/ewm.jpg" alt="微信服务号二维码" /></div> </div> <div class="span6 col-xm-12"> <div class="quick_navigation"> <div class="quick_navigation_title">快速导航</div> <ul> <li><a href="http://www.cdxwcx.cn/tuoguan/neijiang.html" title="内江服务器托管" target="_blank">内江服务器托管</a></li><li><a href="http://www.idckuai.cn/" title="域名注册" target="_blank">域名注册</a></li><li><a href="https://www.cdxwcx.com/jifang/mianyang.html" title="绵阳主机托管" target="_blank">绵阳主机托管</a></li><li><a href="https://www.cdxwcx.com/wangzhan/app.html" title="app开发公司" target="_blank">app开发公司</a></li><li><a href="http://www.cdxwcx.cn/tuoguan/ershu.html" title="成都枢纽中心" target="_blank">成都枢纽中心</a></li><li><a href="https://www.cdcxhl.com/seo.html" title="成都网站营销" target="_blank">成都网站营销</a></li><li><a href="https://www.scvps.cn/" title="申请域名" target="_blank">申请域名</a></li> </ul> </div> </div> </div> </div> <div class="span4 col-xm-6 col-xs-12"> <div class="footer_list"> <div class="footer_link"> <div class="footer_link_title">友情链接</div> <ul id="frientLinks"> <a href="https://www.cdcxhl.com/" title="网站制作" target="_blank">网站制作</a> <a href="https://www.cdcxhl.com/" title="网站建设" target="_blank">网站建设</a> <a href="https://www.cdxwcx.com/tuiguang/" title="成都网络推广" target="_blank">网络推广</a> <a href="http://seo.cdkjz.cn/" title="成都网站推广" target="_blank">网站推广</a> <a href="https://www.cdcxhl.com/xiaochengx.html" title="成都微信小程序开发" target="_blank">小程序开发</a> <a href="https://www.cdcxhl.com/menu.html" title="创新互联网站栏目导航" target="_blank">网站导航</a> </ul> <div class="footer_link_title">网站建设</div> <ul id="frientLinks"> <li><a href="/">营山大橙子建站</a></li> <li><a href="https://www.cdcxhl.com/menu.html" title="创新互联网站栏目导航" target="_blank">网站导航</a></li> </ul> </div> </div> </div> <div class="span4 col-xm-6 col-xs-12"> <div class="footer_list"> <div class="footer_cotact"> <div class="footer_cotact_title">联系方式</div> <ul> <li><span class="footer_cotact_type">企业:</span><span class="footer_cotact_content">青羊区大橙子信息咨询工作室</span></li> <li><span class="footer_cotact_type">地址:</span><span class="footer_cotact_content">成都市青羊区太升南路288号</span></li> <li><span class="footer_cotact_type">电话:</span><span class="footer_cotact_content"><a href="tel:18980820575" class="call">18980820575</a></span></li> <li><span class="footer_cotact_type">网址:</span><span class="footer_cotact_content"><a href="/" title="营山网站建设">www.scyingshan.cn</a></span></li> </ul> </div> </div> </div> </div> </div> <div class="copyright"> <p>公司名称:青羊区大橙子信息咨询工作室 联系电话:18980820575</p> <p><a href="http://beian.miit.gov.cn" target="_blank" rel="nofollow">网站备案号:蜀ICP备2022028542号-24</a></p> <p>营山大橙子建站 营山网站建设 营山网站设计 营山网站制作 <a href="http://www.cdxwcx.cn/" target="_blank">成都做网站</a></p> </div> </div> </div> </div> </body> </html> <script> $(".technical_support_box_z_info_box 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>