更新面板中的转发器中的按钮单击是否触发,直到AsyncPostBackTrigger计时器打勾?

时间:2010-12-16 16:26:30

标签: c# asp.net vb.net asp.net-ajax

我有一个奇怪的问题,想知道是否有人可以提供帮助。

我有一个更新面板,其定时器设置为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

由于

贝克斯

3 个答案:

答案 0 :(得分:0)

<%# Eval("EventChecklistId")%>

这可能是原因。里面有什么价值?它可能需要完整的回发来评估。

答案 1 :(得分:0)

您应该使用Repeater的itemCommand事件来捕获按钮单击,例如

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

并且您可以在此方法中将e参数作为e.CommandArgument进行相应处理。

答案 2 :(得分:0)

似乎还有其他因素导致按钮出现,好像在定时器点击之前没有被触发。 因此,没有其他答案是一个问题,虽然知道未来有用.. 我将此标记为关闭问题的答案..

随意删除