成都创新互联网站制作重庆分公司

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://cxhlcq.com/article/isjsho.html">http://cxhlcq.com/article/isjsho.html</a> </div> </div> </div> <div class="other container"> <h3>其他资讯</h3> <ul> <li> <a href="/article/gcciep.html">oracle12crac搭建时主机名无效问题的解决</a> </li><li> <a href="/article/gcciho.html">Vue.js组件props数据验证实现详解</a> </li><li> <a href="/article/gccigj.html">memcache和memcached在php中的应用</a> </li><li> <a href="/article/gccipi.html">php实现图片压缩不失真的方法</a> </li><li> <a href="/article/gccgds.html">Swing中JFormattedTextField组件如何使用</a> </li> </ul> </div> <div class="footer"> <div class="foota container"> <div class="foot_nav fl col-lg-8 col-md-8 col-sm-12 col-xs-12"> <ul> <li class="col-lg-3 col-md-3 col-sm-3 col-xs-6"> <h3>网站制作</h3> <a href="http://chengdu.xwcx.net/mobile/" target="_blank">移动手机网站制作</a><a href="https://www.cdcxhl.com/mobile.html" target="_blank">手机网站制作</a><a href="http://www.cdxwcx.cn/bj/" target="_blank">网站制作报价</a><a href="http://www.cxjianzhan.com/" target="_blank">网站制作公司</a><a href="http://www.scyanting.com/" target="_blank">盐亭网站制作公司</a><a href="http://m.cdcxhl.cn/dingzhi/" target="_blank">定制网站制作</a> </li> <li class="col-lg-3 col-md-3 col-sm-3 col-xs-6"> <h3>企业服务</h3> <a href="https://www.cdcxhl.com/shoulu/" target="_blank">网站快速收录</a><a href="https://www.cdcxhl.com/mianfei/jianshe/chengdu.html" target="_blank">免费网站建设</a><a href="https://www.cdcxhl.com/shoulu/" target="_blank">免费收录</a><a href="https://www.cdcxhl.com/service/beian.html" target="_blank">网站备案</a><a href="https://www.cdcxhl.com/link/" target="_blank">友情链接购买</a><a href="https://www.cdcxhl.com/ruanwen/" target="_blank">软文发布</a> </li> <li class="col-lg-3 col-md-3 col-sm-3 col-xs-6"> <h3>网站建设</h3> <a href="https://www.cdcxhl.com/" target="_blank">网站建设</a><a href="http://www.cxhljz.cn/" target="_blank">成都网站建设</a><a href="http://chengdu.cdcxhl.cn/dingzhi/" target="_blank">成都定制网站建设</a><a href="http://www.cxjianzhan.com/" target="_blank">成都网站建设公司</a><a href="http://www.cqcxhl.com/" target="_blank">重庆网站建设公司</a><a href="https://www.cdxwcx.com/city/jiangyou/" target="_blank">江油网站建设</a> </li> <li class="col-lg-3 col-md-3 col-sm-3 col-xs-6"> <h3>服务器托管</h3> <a href="https://www.cdcxhl.com/tuoguan/" target="_blank">IDC机房托管</a><a href="https://www.cdcxhl.com/tuoguan.html" target="_blank">成都服务器托管</a><a href="https://www.cdcxhl.com/idc/cqhx.html" target="_blank">重庆电信回兴机房托管</a><a href="https://www.cdcxhl.com/idc/cqstsx.html" target="_blank">重庆水土双线托管</a><a href="https://www.xwcx.net/tgxq/cdghjf.html" target="_blank">成都光华机房</a><a href="http://www.cdxwcx.cn/tuoguan/mianyang.html" target="_blank">绵阳服务器托管</a> </li> </ul> </div> <div class="footar fl col-lg-4 col-md-4 col-sm-12 col-xs-12"> <p>全国免费咨询:</p> <b>400-028-6601</b> <p>业务咨询:028-86922220 / 13518219792</p> <p>节假值班:18980820575 / 13518219792</p> <p>联系地址:成都市太升南路288号锦天国际A幢1002号</p> </div> </div> <div class="footb"> <div class="copy container"> <div class="fl">Copyright © 成都创新互联科技有限公司重庆分公司 <a href="https://beian.miit.gov.cn/" target="_blank">渝ICP备2021005571号</a></div> <!--<div class="fr"><a href="https://www.cdxwcx.com/" target="_blank">成都网站建设</a>:<a href="https://www.cdcxhl.com/" target="_blank">创新互联</a></div>--> </div> </div> <div class="link"> <div class="container"> 友情链接:: <a href="https://www.cdcxhl.com/" target="_blank">成都网站建设</a> <a href="https://www.cdcxhl.com/city/chongqing.html" target="_blank">重庆网站建设</a> <a href="">四川网站建设</a> <a href="">重庆建设网站</a> <a href="https://www.cdxwcx.com/jifang/xiyun.html" target="_blank">移动服务器托管</a> <a href="http://www.cdfuwuqi.com/" target="_blank">成都服务器托管</a> <a href="https://www.cdcxhl.cn/" target="_blank">云服务器</a> <a href="http://www.cdhuace.com/" target="_blank">广告设计制作</a> <a href="https://www.cdcxhl.com/sheji/chongqing.html" target="_blank">重庆网页设计</a> <a href="https://www.cdcxhl.com/zuo/chongqing.html" target="_blank">重庆做网站</a> <a href="https://www.cdcxhl.com/zhizuo/chongqing.html" target="_blank">重庆网站制作</a> <a href="">重庆网站建设</a> <a href="">重庆网站公司</a> <a href="">渝中网站制作</a> <a href="">重庆网站设计</a> </div> </div> </div> <div class="foot"> <ul class="public-celan"> <li> <a href="https://p.qiao.baidu.com/cps3/chatIndex?siteToken=6ce441ff9e2d6bedbdfc2a4138de449e&speedLogId=162260383240185e3_1622603832401_02407&eid=6256368&reqParam=%7B%22from%22%3A1%2C%22sessionid%22%3A%22-100%22%2C%22siteId%22%3A%2211284691%22%2C%22tid%22%3A%22-1%22%2C%22userId%22%3A%226256368%22%2C%22ttype%22%3A1%2C%22pageId%22%3A0%7D" target="_blank" class="a1 db tc"> <img src="/Public/Home/img/icon-23.png" alt="" class="db auto"> <span class="span-txt">在线咨询</span> </a> </li> <li> <a href="tel:18980820575" class="a1 db tc"> <img src="/Public/Home/img/icon-24.png" alt="" class="db auto"> <span class="span-txt">电话咨询</span> </a> </li> <li> <a target="_blank" href="tencent://message/?uin=1683211881&Site=&Menu=yes" class="a1 db tc"> <img src="/Public/Home/img/icon-25.png" alt="" class="db auto"> <span class="span-txt">QQ咨询</span> </a> </li> <li> <a target="_blank" href="tencent://message/?uin=532337155&Site=&Menu=yes" class="a1 db tc public-yuyue-up"> <img src="/Public/Home/img/icon-26.png" alt="" class="db auto"> <span class="span-txt">预约顾问</span> </a> </li> </ul> </div> <div class="customer"> <dl class="icon1"> <dt> <a href="tencent://message/?uin=1683211881&Site=&Menu=yes"> <i class="iconT"><img src="/Public/Home/img/QQ.png" alt=""></i> <p>在线咨询</p> </a> </dt> </dl> <dl class="icon2"> <dt><i><img src="/Public/Home/img/weixin.png" alt=""></i><p>微信咨询</p></dt> <dd><img src="/Public/Home/img/ewm.png"></dd> </dl> <dl class="icon3"> <dt><i><img src="/Public/Home/img/dianhua.png" alt=""></i><p>电话咨询</p></dt> <dd> <p>028-86922220(工作日)</p> <p>18980820575(7×24)</p> </dd> </dl> <dl class="icon4"> <dt class="sShow"> <a href="tencent://message/?uin=244261566&Site=&Menu=yes"> <i><img src="/Public/Home/img/dengji.png" alt=""></i><p>提交需求</p> </a> </dt> </dl> <dl class="icon5"> <dt class="gotop"> <a href="#top"> <i><img src="/Public/Home/img/top.png" alt=""></i><p>返回顶部</p> </a> </dt> </dl> </div> </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); } }); window.onload=function(){ document.oncontextmenu=function(){ return false; } } </script>