2

当我不想更新 .NET 更新面板时,我遇到了问题。

我正在使用 .NET Ajax 和 Twitter Bootstrap Javascript 的组合。我在一个页面上有两个更新面板(您会注意到两个面板都将 ChildrenAsTriggers 设置为 false 并将 UpdateMode 设置为条件,因此我不知所措!!):

小组 1:

            <asp:UpdatePanel ID="upAreas" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
                <ContentTemplate>
                    <asp:Literal ID="litEmptyAreas" runat="server" Text="You currently have no goals or actions." Visible="false" />
                    <asp:Repeater ID="rptAreas" runat="server" 
                        OnItemDataBound="getAreaGoals" >
                        <ItemTemplate>
                                <div class="accordion-group" id="areagroup">
                                <div class="accordion-heading area-heading">
                                    <a class="accordion-toggle" data-toggle="collapse" href='#collapse-<%# Eval("area_id") %>' >
                                        <div class="areatitle">
                                        <asp:Literal ID="litAreaTitle" runat="server" Text='<%# Eval("area_title") %>' />
                                        <!-- <span class="areacreatedate"><asp:Literal ID="litAreaCreateDate" runat="server" Text='<%# "created " + String.Format("{0:dd MMMM yyyy}", Eval("area_createdate")) %>' /></span>-->
                                        </div>
                                    </a>
                                    <div class="areaicons">
                                        <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-plus-sign icon-white areaiconplus"></i></a>
                                        <!--<a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-file icon-white areaiconlist"></i></a>-->
                                        <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-eye-open icon-white areaiconeye"></i></a>
                                    </div>
                                </div>
                                <div id='collapse-<%# Eval("area_id") %>' class="accordion-body collapse">
                                    <div class="accordion-inner">
                                    <asp:Literal ID="litEmptyGoals" runat="server" Text="You currently have no goals or actions for this life area." Visible="true" />
                                    <asp:Repeater ID="rptGoals" runat="server"
                                        OnItemDataBound="setUpGoals" >
                                        <ItemTemplate>
                                            <div class="theGoals clearfix">      
                                                <span class="goalid"><%# Eval("goal_id") %></span>          
                                                <span class="goaltitle"><asp:Literal ID="theGoal" runat="server" Text='<%# Eval("goal_title") %>' /></span>
                                                <div class="goalicons">
                                                    <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-plus-sign icon-white goal_iconplus"></i></a>
                                                    <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-eye-open icon-white goal_iconeye"></i></a>
                                                </div>
                                                <span class="goalduedate"><asp:Literal ID="theDuedate" runat="server" Text='<%# "<span>Due:</span> " + String.Format("{0:dd MMM yy}", Eval("goal_duedate")) %>' Visible="true" /></span>
                                            </div>                                        
                                        </ItemTemplate>
                                    </asp:Repeater>
                                    </div>
                                </div>
                                </div>                    
                        </ItemTemplate>
                    </asp:Repeater>
                </ContentTemplate>
            </asp:UpdatePanel>

这在 Page_Load 中填充,但可能需要稍后在用户添加新项目时进行更新。

当用户单击此更新面板中的 div 时,它应该更新页面上的第二个更新面板。(仅供参考,面板没有嵌套)

小组 2:

<asp:UpdatePanel ID="upActionlist" runat="server" UpdateMode="Conditional" OnLoad="getActions" ChildrenAsTriggers="false">
                <ContentTemplate>
                    <div class="listheading">
                        <div class="goaltitle">
                            <asp:Literal ID="litGoalTitle" runat="server" Text="Nationally Recognised Consultancy" />
                        </div>
                        <div class="goalicons">
                            <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-plus-sign icon-white goaliconplus"></i></a>
                            <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-eye-open icon-white goaliconeye"></i></a>
                        </div>
                    </div>
                    <div class="listinner">
                        <asp:Literal ID="litEmptyActions" runat="server" Text="You currently have no actions to view." Visible="true" />
                        <asp:Repeater ID="rptActions" runat="server" 
                            OnItemDataBound="setUpActions">
                            <ItemTemplate>
                                <div class="theActions clearfix">
                                    <div class="actiontitle">      
                                        <span class="actionid"><%# Eval("item_id") %></span>          
                                        <asp:Literal ID="theAction" runat="server" Text='<%# Eval("item_title") %>' />
                                    </div>
                                    <div class="actionicons">
                                        <!--<a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-th-list icon-white actioniconlist"></i></a>
                                        <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-file icon-white actioniconnote"></i></a>-->
                                        <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-eye-open icon-white actioniconeye"></i></a>
                                        <a href="#" data-toggle="modal" data-target= "#myModal"><i class="icon-check icon-white actioniconcomplete"></i></a>
                                    </div>
                                    <div class="actiondate">
                                        <span class="actionduedate"><asp:Literal ID="theActionduedate" runat="server" Text='<%# "<span>Due:</span> " + String.Format("{0:dd MMM yy}", Eval("item_duedate")) %>' Visible="true" /></span>
                                    </div>
                                </div>  
                            </ItemTemplate>
                        </asp:Repeater>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>

使用添加到 document.ready 的第一个更新面板中的 DIV 的以下 javascipt click 事件调用更新:

        $('.theGoals').click(function () {
            //remove from all goal other classes
            $('.theGoals').removeClass('active'); // "this" is the current element in the loop

            $(this).addClass('active');

            // Load content
            __doPostBack('<%=upActionlist.ClientID %>', $(this).children('.goaltitle').text() + "|" + $(this).children('.goalid').text());

        });

当它运行这个 javascript 时,它会更新两个面板,而不仅仅是第二个面板。感激地收到任何帮助,因为这让我发疯。

4

1 回答 1

0

我通过在页面上放置一个 hiddenasp:button并从客户端调用它的 click 方法来强制正确回发来解决这个问题:

JS:

$('#<%=bla.ClientID %>').click();
于 2013-01-03T14:06:33.357 回答