上传面板和计时器完全刷新页面:(

时间:2012-01-02 23:31:18

标签: asp.net

我有一个updatepanel和一个计时器。

我想刷新我的更新面板但是当我在updatepanel中放置一个计时器时它不起作用,当我把它放在我的页面之外时它会。

我该怎么办?

<asp:UpdatePanel runat="server" ID="updLastAouction" UpdateMode="Conditional">
                <ContentTemplate>


        مزایده شماره : <asp:Label runat="server" ID="lbAuctionID"></asp:Label>

       <br/>
       <div style="margin-bottom: 10px;">
        آخرین قیمت پیشنهادی :
        </div>
            <asp:Label runat="server" ID="lbLastOrderPrice"></asp:Label>

        <div class="lastBidder">
            <div style="margin-bottom: 10px;">
            آخرین پیشنهاد دهنده
            </div>
            <asp:Label runat="server" ID="lbLastBidder">ندارد</asp:Label>
        </div>
        <div class="lastBidder" style="margin-top:5px;margin-bottom: 5px;">
            <div class="font">
            زمان باقی مانده</div>

            <asp:Label runat="server" ID="lbLeftTime" Text='<%#DateTime.Now.ToLongTimeString() %>'></asp:Label>
            <br/>
        </div>
        <asp:Button runat="server" ID="btnLastAouction" Text="برای شرکت عضو شوید" 
                        onclick="btnLastAouction_Click"/>
                    </ContentTemplate>
            </asp:UpdatePanel><asp:Timer ID="timerLastAouction" runat="server" Interval="1000" 
                        OnTick="timerLastAouction_Tick" />

1 个答案:

答案 0 :(得分:3)

如果Timer不在UpdatePanel内,它将导致完整的回发。您可以向UpdatePanel添加AsyncPostbackTigger

<Triggers>
   <asp:AsyncPostBackTrigger ControlID="timerLastAouction" EventName="Tick" />
</Triggers>

或者您可以将Timer Control包装在单独的UpdatePanel中以避免整页回发。

<asp:UpdatePanel runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false"
    ID="upTimer">
    <ContentTemplate>
        <asp:Timer ID="timerLastAouction" runat="server" Interval="1000" OnTick="timerLastAouction_Tick">
        </asp:Timer>
    </ContentTemplate>
</asp:UpdatePanel>
相关问题