整个页面刷新,甚至控制在更新面板内

本文关键字:控制 更新 刷新 | 更新日期: 2023-09-27 17:51:14

我在一个问题上卡住了。我的主页,我在哪里使用标题横幅。我已经为更新面板内的横幅图像设置了计时器。但是,当我向下滚动页面以阅读主页文本时,页面刷新并滚动到顶部。

您可以在以下链接查看此问题:

http://www.sspos.net/mb/index.aspx

下面是我的代码:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
     <asp:UpdatePanel runat="server" ID="SlideShow" UpdateMode="Always">
    <ContentTemplate>
   <div id="lsmoke">
<div class="displayimg">
     <asp:Timer runat="server" Interval="5000" ID="SlideShowTimer" OnTick="SlideShowTimer_Tick" />
         <img runat="server" id="SlideShowImage1" src="Images/lsmoke_banner2.PNG"   class="displayimg" style="width:720px;"
            alt="" />
    </div>
       </div>
        </ContentTemplate>
                             <Triggers>
        <asp:AsyncPostBackTrigger ControlID="SlideShowTimer" EventName="Tick" />
    </Triggers>
          </asp:UpdatePanel>

    <p>
    Prime Wholesale is an online wholesaler of general merchandise and
    <span id="e1cak1u_2" class="e1cak1u">tobacco</span>
    products.
    </p>

        <p>
    Our tobacco product selection includes pipe tobacco, premium and machine rolled
    <span id="e1cak1u_1" class="e1cak1u">cigars</span>
    and cigarillos, little and filtered cigars, hookahs, glass pipes, RYO and other smoking accessories.
    </p>
    <p>While we accept orders of any dollar amount, our pricing model is trimmed for bigger orders and targets gas stations, convenience stores, tobacco stores, cigar stores and other business customers.</p>
    <p>In particular, our prices are as low as possible while shipping cost is rather high.</p>
    <p>However, as soon as your order exceeds $500 value, we will ship your order for $1.</p>
    <p>Some products may be sold at a price below minimum retail price allowed by manufacturer. We can do that only because we're not a retail business and we offer the products in wholesale quantities.</p>
    <p>The most preferrable form of payment for us is bank transfer, but we also accept major credit cards.</p>


         <ajax:UpdatePanelAnimationExtender runat="server" ID="UPextender" TargetControlID="SlideShow"
        BehaviorID="animation">
        <Animations>
           <OnUpdating>
                <FadeOut Duration=".5" Fps="20" minimumOpacity=".1" />
            </OnUpdating>
            <OnUpdated>
                <FadeIn Duration="1.5" Fps="20" minimumOpacity=".1" />
            </OnUpdated>
        </Animations>
    </ajax:UpdatePanelAnimationExtender>



    </asp:Content>
下面是代码后面的代码:
      Protected Sub SlideShowTimer_Tick(sender As Object, e As EventArgs)
        Dim later As DateTime = DateTime.Now.AddSeconds(0.5)
        While DateTime.Now < later
        End While
        Me.SlideShowImage1.Src = RandomImageName()

    End Sub
    Private Function RandomImageName() As String
        Dim rand As New Random()
        Dim RandomInt As Integer = rand.[Next](0, 5)
        Select Case RandomInt
            Case 0
                Return "Images/lsmoke_banner1.PNG"
                Exit Select
            Case 1
                Return "Images/lsmoke_banner2.PNG"
                Exit Select
            Case 2
                Return "Images/lsmoke_banner3.PNG"
                Exit Select
            Case 3
                Return "Images/lsmoke_banner4.PNG"
                Exit Select
            Case 4
                Return "Images/lsmoke_banner5.PNG"
                Exit Select
            Case 5
                Return "Images/lsmoke_banner1.PNG"
                Exit Select
            Case Else
                Return "Images/lsmoke_banner2.PNG"
                Exit Select
        End Select
    End Function

请告诉我哪里做错了

整个页面刷新,甚至控制在更新面板内

您使用的是每次刷新页面的服务器端组件,请尝试使用客户端组件(如javascript脚本)更改图片,这将确保页面不会在每个循环中刷新。

一些例子

http://jquery.malsup.com/cycle/

http://blog.lynda.com/2012/02/10/create-a-jquery-photo-rotator-in-15-lines-of-code/