2010-12-16 24 views
1

我有一個奇怪的問題,想知道是否有人可以幫忙。按鈕點擊中繼器在updatepanel中沒有觸發,直到AsyncPostBackTrigger計時器打勾?

我有一個更新面板,其定時器設置爲AsyncPostBackTrigger。 在這個更新面板中,我有一箇中繼器,在中繼器中有幾個按鈕,它們具有點擊事件。

點擊這些按鈕不會出現直到定時器打勾。 我已經嘗試過調試,這是似乎正在發生的事情,無論哪種方式,它需要年齡爲按鈕點擊實際上觸發。

有沒有人知道爲什麼會這樣,我能做些什麼呢?

我的代碼如下:

更新面板

<asp:UpdatePanel ID="CheckListUpdatePanel" runat="server"> 
    <ContentTemplate> 

    <div><asp:Label ID="CannotBeLoadedLabel" runat="server" Visible="false"></asp:Label></div> 
     <table> 
      <asp:Repeater ID="ChecklistRepeater" runat="server"> 

       <ItemTemplate> 
        <tr> 

         <td> 
          <%# Eval("Description")%> 
         </td> 

         <td> 
          <%# Eval("Priority")%> 
         </td> 
         <td> 

         <td> 
          <asp:Button ID="SetAsCompleteButton" CommandArgument='<%# Eval("EventChecklistId")%>' 
           runat="server" OnClick="SetAsCompleteButton_Click" Text="Close" /> 
         </td> 
        </tr> 
       </ItemTemplate> 
      </asp:Repeater> 
     </table> 
</ContentTemplate> 
    <Triggers> 
     <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> 
    </Triggers> 
</asp:UpdatePanel> 

我的一些代碼背後:

Protected Sub SetAsCompleteButton_Click(ByVal sender As Object, ByVal e As EventArgs) 
     timer1.Enabled = False 

~~do complete code  

     timer1.Enabled = True 
    End Sub 

Protected Sub timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles timer1.Tick 
     timer1.Enabled = False 
     LoadEventChecklist() 
     timer1.Enabled = True 
    End Sub 

感謝

貝克斯

回答

0
<%# Eval("EventChecklistId")%> 

這可能是原因。裏面的價值是什麼?它可能需要完整的回發評估。

+0

這是必然的ID值數據源給中繼器。該按鈕需要這個值,當它回來知道它設置完成的項目。有沒有辦法呢? – Bex 2010-12-16 16:51:41

+0

你不能通過ClientID,它已經存在 <%= DataSourceControl.ClientID%> – 2010-12-16 16:54:33

+0

你是什麼意思?將整個數據源傳遞給代碼?我從背後的代碼綁定了這個,如果這就是你的意思,我沒有使用數據源控件? – Bex 2010-12-16 16:56:24

0

您應該使用ItemCommand事件的Repeater捕捉按鈕點擊,像

protected void ChecklistRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) 
{ 
    e.CommandArgument // This will give the argument specified in the button 
     //Your Code 
} 

,你可以得到事件參數作爲e.CommandArgument這個方法裏面進行相應的處理。

+0

謝謝你!它的其他東西導致它看起來好像在等待計時器滴答聲。 – Bex 2010-12-17 10:08:59

0

似乎還有其他東西導致按鈕出現,就好像在定時器單擊之前它沒有被觸發一樣。所以,沒有任何其他的答案 是一個問題,雖然很有必要知道爲未來.. 我標誌着這個作爲答案,關閉問題..

隨意刪除

相關問題