为什么当AssociatedUpdatePanelId设置更新进度不火? [英] Why does Update Progress does not fire when AssociatedUpdatePanelId is set?

查看:89
本文介绍了为什么当AssociatedUpdatePanelId设置更新进度不火?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我指定AssociatedUpdatePanelId,当我选择一个国家进步不显示,但是当我将其留空,则显示进度。

下面是ASPX标记:

 < D​​IV>
    < ASP:列表框ID =lstStates=服务器的AutoPostBack =真
    OnSelectedIndexChanged =lstStates_SelectedIndexChanged的SelectionMode =多>
    < / ASP:列表框>
< / DIV>
< D​​IV>
    < ASP:的UpdatePanel ID =UpdatePanel1=服务器>
    <&的ContentTemplate GT;
    < ASP:面板ID =pnlCounty=服务器>
    < ASP:列表框ID =lstCounties=服务器的SelectionMode =多>
    < / ASP:列表框>
    < / ASP:面板>
    < /&的ContentTemplate GT;
    <&触发器GT;
    < ASP:AsyncPostBackTrigger控件ID =lstStates事件名称=的SelectedIndexChanged/>
    < /触发器>
    < / ASP:的UpdatePanel>
    < ASP:的UpdateProgress ID =UpdateProgress2=服务器DisplayAfter =1
                        AssociatedUpdatePanelID =UpdatePanel1>
    < ProgressTemplate>
    < IMG SRC =../图像/ loader2.gif/>
    加载县...
    < / ProgressTemplate>
    < / ASP:&的UpdateProgress GT;
< / DIV>


解决方案

据<一个href=\"http://www.$c$cdigest.com/Articles/ASPNETAJAX/125%5FUsing%5FUpdateProgress%5FControl%5FEffectively.aspx\">this文章,对于一个UpdatePanel外部触发器不火关联的UpdateProgress,因为使UpdateProgress控件执行搜索呼叫控制控件层次结构;外部触发将不会被present在控制层次。

这篇文章确实,但是,建议注入一些JavaScript来弥补这个错误;我把它修改为(希望)适合您的需要:

 &LT;脚本类型=文/ JavaScript的LANGUAGE =JavaScript的&GT;
    功能页面加载()
    {
       VAR经理= Sys.WebForms.PageRequestManager.getInstance();
       manager.add_endRequest(endRequest);
       manager.add_beginRequest(OnBeginRequest);
    }
    功能OnBeginRequest(发件人,参数)
    {
      变种postBackElement = args.get_postBackElement();
      如果(postBackElement.id =='lstStates')
      {
     $得到('UpdateProgress2')的style.display =块。
      }
   }
&LT; / SCRIPT&GT;

When I assign the AssociatedUpdatePanelId, the progress does not display when I select a state, but when I leave it blank, it displays the progress.

Here is the aspx markup:

<div>
    <asp:ListBox ID="lstStates" runat="server" AutoPostBack="True"
    OnSelectedIndexChanged="lstStates_SelectedIndexChanged" SelectionMode="Multiple">
    </asp:ListBox>
</div>
<div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <asp:Panel ID="pnlCounty" runat="server">
    <asp:ListBox ID="lstCounties" runat="server" SelectionMode="Multiple">
    </asp:ListBox>
    </asp:Panel>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="lstStates" EventName="SelectedIndexChanged" />
    </Triggers>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="UpdateProgress2" runat="server" DisplayAfter="1"
                        AssociatedUpdatePanelID="UpdatePanel1">
    <ProgressTemplate>
    <img src="../images/loader2.gif" />
    Loading Counties...
    </ProgressTemplate>
    </asp:UpdateProgress>
</div>

解决方案

According to this article, external triggers for an UpdatePanel do not fire an associated UpdateProgress, since the implementation of enabling the UpdateProgress control searches the control hierarchy for the calling control; an external trigger will not be present in the control hierarchy.

The article does, however, suggest injecting some JavaScript to make up for this error; I have modified it to (hopefully) fit your needs:

<script type="text/JavaScript" language="JavaScript">
    function pageLoad()
    {      
       var manager = Sys.WebForms.PageRequestManager.getInstance();
       manager.add_endRequest(endRequest);
       manager.add_beginRequest(OnBeginRequest);
    }
    function OnBeginRequest(sender, args)
    {
      var postBackElement = args.get_postBackElement();
      if (postBackElement.id == 'lstStates')
      { 
     $get('UpdateProgress2').style.display = "block";  
      }
   }
</script>

这篇关于为什么当AssociatedUpdatePanelId设置更新进度不火?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆