避免回发,而做一个计时器滴答功能 [英] Avoid post back while doing a timer tick function

查看:194
本文介绍了避免回发,而做一个计时器滴答功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做更新的图像在我的网站,而在page.So做回发,我加载广告旋转图像图像之间toggl。

我还使用了计时器滴答功能刷新图像广告旋转器。

但是,当计时器滴答功能刷新整个页面被刷新,使我在页面上声明的所有功能被重新装入。

我需要在广告旋转图像仅适用于图像不应该刷新整个页面。

我需要避免页面刷新的整体。
请帮助我。

  $(文件)。就绪(函数(){
    的setInterval(函数(){
        $('#&下;%= addrotat.ClientID%GT;')。载荷(location.href +#&下;%= addrotat.ClientID%GT;',''+的Math.random()+'');
    },5000);
});


解决方案

  //自动刷新时钟不回传<身体GT;
    <表ID =form1的=服务器>
        < ASP:的ScriptManager ID =ScriptManager1=服务器>
            <脚本类型=文/ VBSCRIPT=服务器>
                私人小组乐趣()
                    label.Text = Now.ToString
                结束小组
            < / SCRIPT>
        < / ASP:ScriptManager的>
        < D​​IV>
            < ASP:的UpdatePanel ID =上一条=服务器>
                <&的ContentTemplate GT;< /&的ContentTemplate GT;
                <&触发器GT;
                    < ASP:AsyncPostBackTrigger控件ID =添事件名称=嘀/>
                < /触发器>
                <&的ContentTemplate GT;
                    < ASP:定时器ID =添间隔=1000启用=真OnTick =好玩=服务器>< / ASP:定时器>
                    < ASP:标签ID =标签=服务器文本=DD / MM / YY>< / ASP:标签>
                < /&的ContentTemplate GT;
            < / ASP:的UpdatePanel>
        < / DIV>
    < /表及GT;
< /身体GT;

i need to do update images in my site without doing post back in a page.So, i loaded the images in ad-rotator to toggl between images.

I also used the timer tick function to refresh the images in the ad-rotator.

But while timer tick function refresh the whole page is refreshed so that all functions that i declared in the page is reloaded.

i need to only images in the ad-rotator images should refresh not the whole page.

i need to avoid whole refresh of the page. Pls help me.

$(document).ready(function() {
    setInterval(function() {
        $('#<% = addrotat.ClientID %>').load(location.href + ' #<% = addrotat.ClientID %> ', '' + Math.random() + '');
    }, 5000);
});

解决方案

//auto refresh clock without postback

<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <script type="text/vbscript" runat ="server" >
                Private Sub fun()
                    label.Text = Now.ToString
                End Sub
            </script>
        </asp:ScriptManager>
        <div>
            <asp:UpdatePanel ID="up1" runat="server">
                <ContentTemplate ></ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="tim" EventName="Tick" />
                </Triggers>
                <ContentTemplate>  
                    <asp:Timer ID="tim" Interval ="1000" Enabled ="true " OnTick ="fun" runat ="server" ></asp:Timer>
                    <asp:Label ID="label" runat ="server" Text="DD/MM/YY"></asp:Label>     
                </ContentTemplate>
            </asp:UpdatePanel>  
        </div>
    </form>
</body>

这篇关于避免回发,而做一个计时器滴答功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆