2012-12-29 63 views
2

當我不需要它時,.NET更新面板更新有問題。在另一個更新面板上使用__doPostBack時停止更新面板更新

我正在使用.NET Ajax和Twitter Bootstrap Javascript的組合。我有一個頁面上有兩個更新面板(你會發現兩個面板有ChildrenAsTriggers設置爲false的UpdateMode設置爲條件,因此事實上,我不知所措!):

PANEL 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時,它應該更新頁面上的第二個更新面板。 (FYI的面板是不嵌套的)

PANEL 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> 

更新使用被稱爲以下javascipt的點擊事件加入到在的document.ready第一更新面板DIV:

 $('.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運行時,它更新兩個面板,而不僅僅是第二個面板。感激地收到了任何幫助,因爲這讓我發瘋。

回答

0

我解決這個問題,通過把一個隱藏asp:button頁面上,把它的點擊方法從客戶端進行力適當的回傳:

JS:

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