ASP TImer,UpdatePanel和UpdatePanelAnimationExtender

时间:2016-04-21 15:34:22

标签: asp.net timer updatepanel ajaxcontroltoolkit

当我使用Timer事件标记来触发动画更新面板刷新时,我收到以下错误:

TypeError: sender._activeElement is undefined
Sys.Extended.UI.Animation.UpdatePanelAnimationBehavior.prototype._partialUpdateBeginRequest()
 ScriptResource.axd:75
Function$createDelegate/<()
 ScriptResource.axd:47
Sys$EventHandlerList$getHandler/<()
 ScriptResource.axd:3484
Sys$WebForms$PageRequestManager$_onFormSubmit()
 ScriptResource.axd:1284
Sys$WebForms$PageRequestManager$_doPostBack()
 ScriptResource.axd:824
Function$createDelegate/<()
 ScriptResource.axd:47
Sys$UI$_Timer$_doPostback()
 ScriptResource.axd:60
Sys$UI$_Timer$_raiseTick()
 ScriptResource.axd:91
Function$createDelegate/<()

如果我使用button click事件,它可以正常运行动画,但我需要时间。如果我删除了UpdatePanelAnimationExtender,则计时器刷新工作正常,但我没有动画。

我正在使用Ajax Control Toolkit 16

<%@ Page Language="VB" AutoEventWireup="True" CodeFile="Test2.aspx.vb" Inherits="_Default" Debug="True" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <title></title>
    <link href="ds2.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
        <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>

     <div><div style="float:right; color:gray;"><asp:Label Visible="true"  ID="Label1" runat="server" Text="1"></asp:Label></div>
         <ajaxToolkit:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender1" runat="server" TargetControlID="logoUpdatePanel">
             <Animations><OnUpdating><Sequence>
<EnableAction AnimationTarget="effect_color" Enabled="true" />
<EnableAction AnimationTarget="effect_collapse" Enabled="true" />
<EnableAction AnimationTarget="effect_fade" Enabled="true" />
<Parallel Duration="1" Fps="20">
<FadeOut AnimationTarget="PanelInfo" minimumOpacity=".2" />
<color AnimationTarget="PanelInfo" StartValue="#FFEF3F" EndValue="#FFFFFF" Property="style" PropertyKey="backgroundColor" />
</Parallel></Sequence></OnUpdating>
<OnUpdated>
<Sequence>
<EnableAction AnimationTarget="effect_collapse" Enabled="true" />
<EnableAction AnimationTarget="effect_fade" Enabled="true" />
<Parallel Duration="1" Fps="20">
<FadeIn AnimationTarget="logoUpdatePanel" />
<Resize Height="0" />
</Parallel>
</Sequence>
</OnUpdated></Animations>
         </ajaxToolkit:UpdatePanelAnimationExtender>
         <asp:UpdatePanel ID="logoUpdatePanel" runat="server" UpdateMode="Conditional" >
             <ContentTemplate>
                 <asp:Image ID="Logo1" runat="server" ImageUrl="~/Images/RBCCCW_1080p_Horizontal.jpg" ImageAlign="Middle" />
                 <asp:Label Visible="false" runat="server" ID="TableCount" Text="tablecount"></asp:Label>
                 <asp:Label visible="false" runat="server" ID="rowcount" Text="rowcount"></asp:Label>
             </ContentTemplate>
        <Triggers>
               <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
         </asp:UpdatePanel>
     </div>   
    <div>

       <asp:UpdatePanel ID="UpdatePanel1" runat="server" updatemode="Conditional">
        <ContentTemplate> 
            <asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="bindlist"></asp:Timer>
            <asp:DataList ID="RoomEventsList" runat="server" Width="1080px" CellPadding="10" CellSpacing="5" HeaderStyle-BackColor="#0060AA" AlternatingItemStyle-BackColor="#a8cde2" Font-Size="24pt">
                <HeaderTemplate>
                    <div class="colhead1">Start</div><div class="colhead2">Events</div>
                </HeaderTemplate>
                <ItemTemplate>
                            <div class="col1"><%#Eval("fstf").ToString.ToLower()%></div><div class="col2"><span style="font-weight:bold"><%#Eval("EV700_ALT_FUNC_DESC")%></span> <br /><span style="float:right;font-size:22pt"> <%#Eval("EV800_SPACE_DESC")%>  | <%#Eval("EV812_HIER_LVL2_DESC")%> | <%#Eval("EV811_HIER_LVL1_DESC")%> </span></div>
                </ItemTemplate>
                <FooterTemplate>
                </FooterTemplate>
            </asp:DataList>
            <table width="100%"><tr><td></td><td align="right">
                <asp:Label Visible="false" runat="server" ID="pagenumber" Text="start"></asp:Label><asp:Label Visible="false"  ID="lblTotalPages" runat="server" Text="1"></asp:Label></td></tr></table>

             </ContentTemplate>
        <Triggers>
               <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
    </asp:UpdatePanel>

    </div>

    </form>
</body>
</html>

和背后的代码:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Services
Imports System.Collections.Generic
Imports System.Configuration

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim pagedDSr As New PagedDataSource()
    Dim totalPages As Integer
    Dim totalImages As Integer

    Public Property CurrentPage() As Integer
        Get
            Return IIf(ViewState("CurrentPage") Is Nothing, 0, CInt(ViewState("CurrentPage")))
        End Get
        Set(value As Integer)
            ViewState("CurrentPage") = value
        End Set
    End Property

    Public Property imagecount() As Integer
        Get
            Return IIf(ViewState("imagecount") Is Nothing, 0, CInt(ViewState("imagecount")))
        End Get
        Set(value As Integer)
            ViewState("imagecount") = value
        End Set
    End Property

    Public Property imageSize() As String
        Get
            Return IIf(ViewState("imageSize") Is Nothing, "", CStr(ViewState("imageSize")))
        End Get
        Set(value As String)
            ViewState("imageSize") = value
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack() Then
            CurrentPage = 0
            imagecount = 1
            TableCount.Text = "0"
            bindlist()
        End If
    End Sub

    Sub changelogo()
        Logo1.ImageUrl = "~/Images/" & imagesize & "/" & imagecount & ".jpg"
        If imagecount = IO.Directory.GetFiles("C:\inetpub\digsignall\Images\" & imageSize & "\", "*.jpg").Length Then
            imagecount = 1
            TableCount.Text = imagecount.ToString
        Else
            imagecount = imagecount + 1
            TableCount.Text = imagecount.ToString
        End If
    End Sub

    Sub bindlist()
        Dim strConnString As String = ConfigurationManager.ConnectionStrings("ebmsprodCS").ConnectionString
        Dim con As New SqlConnection(strConnString)

        Using conn As New SqlConnection(strConnString)
            Dim varname1 As New System.Text.StringBuilder
            varname1.Append("SELECT statement removed for space")

            Dim cmd As New SqlCommand(varname1.ToString, conn)
            cmd.CommandType = CommandType.Text
            conn.Open()
            'Dim drEvents As SqlDataReader = cmd.ExecuteReader()
            Dim eventsda = New SqlDataAdapter(cmd)
            Dim ds = New DataSet
            eventsda.Fill(ds, "events")


            If ds.Tables(0).Rows.Count <= 0 Then
                    RoomEventsList.Visible = False
                    imagesize = "fullscreen"
                    rowcount.Text = IO.Directory.GetFiles("C:\inetpub\digsignall\Images\" & imageSize & "\", "*.jpg").Length
                    changelogo()
            Else
                RoomEventsList.Visible = True
                imageSize = "top"
                changelogo()
            End If
            pagedDSr.DataSource = ds.Tables(0).DefaultView
            pagedDSr.AllowPaging = True
            pagedDSr.PageSize = 10
            pagedDSr.CurrentPageIndex = CurrentPage
            totalPages = pagedDSr.PageCount
            RoomEventsList.DataSource = pagedDSr
            RoomEventsList.DataBind()
            conn.Close()
            Label1.Text = Request.QueryString("room")
        End Using
        If pagedDSr.IsLastPage Then
            CurrentPage = 0
        Else
            CurrentPage = CurrentPage + 1
        End If
        pagenumber.Text = CurrentPage.ToString
    End Sub

    Protected Sub bindlist_tick()
        pagedDSr.CurrentPageIndex = CurrentPage
        RoomEventsList.DataSource = pagedDSr
        RoomEventsList.DataBind()
        If pagedDSr.IsLastPage Then
            CurrentPage = 0
        Else
            CurrentPage = CurrentPage + 1
        End If
        pagenumber.Text = CurrentPage.ToString
    End Sub
End Class

0 个答案:

没有答案