【问题标题】:Using 'UpdatePanel' still takes my page to the top where there is a slideshow使用“UpdatePanel”仍然会将我的页面带到有幻灯片的顶部
【发布时间】:2014-02-06 08:53:29
【问题描述】:

我在页面顶部有一个幻灯片,在底部有一个表单。但只要幻灯片中的图像发生变化,它就会将我带到页面顶部。所以我不能填写表格或在底部做任何事情。看起来它会再次发布该页面,但我已采取一切必要措施来避免这种情况。

这是我的控件:

      <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                <asp:Timer ID="Timer1" runat="server" Interval="3000"    OnTick="Timer1_Tick">
                </asp:Timer>
                <asp:Image ID="Image1" Height="388px" Width="936px" runat="server" />
                    </ContentTemplate>
            </asp:UpdatePanel>

这里是代码隐藏:

 protected void Timer1_Tick(object sender, EventArgs e)
{
    SetImageUrl();
}
private void SetImageUrl()
{
    Random _rand = new Random();
    int i = _rand.Next(1, 5);
    Image1.ImageUrl = "~/Slideshow/" + i.ToString() + ".jpg";
}

【问题讨论】:

  • 设置&lt;%@ Page MaintainScrollPositionOnPostback="true" %&gt;有帮助吗?
  • 它在我滚动的时候确实有一点帮助。但仍然会用幻灯片发回。

标签: asp.net updatepanel slideshow scriptmanager


【解决方案1】:

试试这个

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                <asp:Timer ID="Timer1" runat="server" Interval="3000"    OnTick="Timer1_Tick">
                </asp:Timer>
                <asp:Image ID="Image1" Height="388px" Width="936px" runat="server" />
                    </ContentTemplate>
<Triggers>
            <asp:PostBackTrigger ControlID="Timer1" />
        </Triggers>
            </asp:UpdatePanel>

【讨论】:

  • 属性“EventName”不是元素“PostBackTrigger”的有效属性。我该如何解决这个错误?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-03
  • 2015-04-07
  • 1970-01-01
  • 1970-01-01
  • 2013-10-26
相关资源
最近更新 更多