刷新页面的特定部分而不刷新整页 [英] Refreshing particular part of Page Without Refreshing Whole Page

查看:63
本文介绍了刷新页面的特定部分而不刷新整页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用下拉列表删除一些文件,我想只刷新下拉列表而不刷新整个页面,以便下拉列表中显示的文件得到更新,我确认文件被删除而不刷新整页。

任何想法,如何...?

解决方案

将您的内容放在 Ajax UpdatePanel 中。并使用 Ajax计时器定期刷新相同的内容。



Ex:

 <   asp:ScriptManager     runat   = 服务器    ID   =  ScriptManager1    /  >  
< asp :计时器 ID = Timer1 runat = server Interval = 1000 OnTick = Timer1_Tick >
< / asp :计时器 >
< asp:UpdatePanel ID = UpdatePanel1 runat < span class =code-keyword> = server > ;
< 触发器 >
< asp:AsyncPostBackTrigger ControlID = Timer1 EventName = < span class =code-keyword>勾选 / >
< / Triggers >
< ContentTemplate >
< asp:标签 ID = Label1 runat = server > < / asp:Label >
< / asp: UpdatePanel >



c#下面的代码..

< pre lang =c#> protected void Timer1_Tick( object sender,EventArgs e)
{
Label1.Text = DateTime.Now.ToShortTimeString()。ToString();
}



以上代码将以1秒的常规间隔获取当前时间。您将代码放在更新面板中,并提供您想要刷新内容的时间..


I am deleting some file using dropdownlist and i want to refresh only dropdownlist without refreshing whole page , so that the files showing in dropdownlist get updated and i get confirmed that file is deleted without refreshing whole page.
Any Idea , How To..?

解决方案

Place your content inside Ajax UpdatePanel. And use Ajax timer to refresh the same content for regular interval of time.

Ex:

<asp:ScriptManager runat="server" ID="ScriptManager1" />
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
      <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
      </Triggers>
      <ContentTemplate>
            <asp:Label ID="Label1" runat="server"></asp:Label>
</asp:UpdatePanel>


c# code below..

protected void Timer1_Tick(object sender, EventArgs e)
{
     Label1.Text = DateTime.Now.ToShortTimeString().ToString();
}


Above code will fetch current time for regular interval of 1 second. You place your code inside update panel and give time as much you wanted to refresh the content..


这篇关于刷新页面的特定部分而不刷新整页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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