开发者

How to make update panel not update whole page?

开发者 https://www.devze.com 2023-04-13 04:02 出处:网络
I have an update panel that has a table in it with 4 images.Every few seconds a new image is shown.All this works but when the image changes the whole page is refreshed.

I have an update panel that has a table in it with 4 images. Every few seconds a new image is shown. All this works but when the image changes the whole page is refreshed.

I am using Visual Studio 2008 and VB.Net 3.5.

I only want the images in the updatepanel to refresh. How can I do that?

UpdatePanel Code:

<asp:UpdatePanel runat="server" ID="upImgSwitch" UpdateMode="Always">
    <ContentTemplate>
        <table height="200px" width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td width="200px">
                    <asp:Image runat="server" ID="ImgBox1" />
                </td>
                <td width="200px">
                    <asp:Image runat="s开发者_开发知识库erver" ID="ImgBox2" />
                </td>
                <td width="200px">
                    <asp:Image runat="server" ID="ImgBox3" />
                </td>
                <td width="200px">
                    <asp:Image runat="server" ID="ImgBox4" />
                </td>
            </tr>
        </table>
    </ContentTemplate>
</asp:UpdatePanel>


It may be that you need to set your UpdatePanels UpdateMode to UpdateMode="Conditional". Any that are set to "Always" will update whenever any UpdatePanel on the page refreshes, whereas if you set it to "Conditional" it will only update if a containing control fires an event, or if UpdatePanel.Update() is called on it.


Add a trigger child to the updatepanel, and place the timer id in where the ControlID is such as Timer1.

<asp:UpdatePanel runat="server" ID="upImgSwitch" UpdateMode="Always">
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="timer1" EventName="Tick" />
  </Triggers>
  <ContentTemplate>

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消