gpt4 book ai didi

javascript - 在另一个更新面板上使用 __doPostBack 时停止更新面板更新

转载 作者:行者123 更新时间:2023-11-30 06:36:31 30 4
gpt4 key购买 nike

我在不希望更新 .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 单击事件调用更新:

        $('.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 运行时,它会更新两个面板,而不仅仅是第二个面板。非常感谢收到的任何帮助,因为这让我发疯。

最佳答案

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

JS:

$('#<%=bla.ClientID %>').click();

关于javascript - 在另一个更新面板上使用 __doPostBack 时停止更新面板更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14085196/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com