网页局部显示 我现在用asp.net写了一个网页,由于显示的内容比较多,我想一块一块的输出,但是不知道改怎么编写代码,哪位大侠比较熟悉稍微介绍一下,非常感谢,我写的这个网页主要有三个大的Div。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要一块一块依次显示的话,可以用Ajax,每个div的内容都是到后台获取, 能说明一下怎么用么?我这两天看了一下UpdatePanel,但是好像进入误区了,还是没有弄出来!!! UpdatePanel是微软封装好的。使用UpdatePanel只需要把你要异步更新的数据放在其标签里面就可以了!好像可以设置更新时间的! 如果使用UpdatePanel,那么就是将三个Panel分别放在三个UpdatePanel内,并且设置它们的Visible为false。使用一个Timer(例如Interval=10毫秒)来控制,每次设置一个Panel的Visible属性为true,直到三个Panel全都为true则停止Timer。 <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div class="itemarea small l"> <span class="subtit">一级关键词</span> <asp:Literal runat="server" ID="FirstKeyWordHTML"></asp:Literal> </div> </ContentTemplate> </asp:UpdatePanel>你看是这种么??? 你可以在显示第二个Panel的时候才去读第二段数据嘛! 给你写了个简单的demo:<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Timer1_Tick(object sender, EventArgs e) { if (!Panel1.Visible) { Panel1.Visible = true; UpdatePanel2.Update(); } else if (!Panel2.Visible) { Panel2.Visible = true; UpdatePanel3.Update(); this.Calendar1.SelectedDate = new DateTime(2010, 10, 1); } else if (!Panel3.Visible) { Panel3.Visible = true; UpdatePanel4.Update(); this.frame.Attributes["src"] = "http://topic.csdn.net/u/20101221/10/1d479fd6-9f09-41a7-bd8e-fc3fce352051.html?seed=1463094318&r=70713815#r_70713815"; } else this.Timer1.Enabled = false; }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="100" OnTick="Timer1_Tick"> </asp:Timer> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="Panel2" runat="server" Visible="false"> <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="Panel3" runat="server" Visible="false"> <iframe id="frame" runat="server" width="100%" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="Panel1" runat="server" Visible="false"> <asp:Image ID="Image1" runat="server" ImageUrl="http://imgsrc.soso.com/imgget.q?id=e422d6d9a9c9b462a61b5e9d37105d87" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> </form></body></html> 可能是我说的有问题吧,我这人就是不知道怎么描述清楚,让大家见笑了!!!我现在所做的一个东西是从网上搜索我需要的数据,然后显示到我本地的aspx页面上,由于数据量是比较大,现在我搜索的话需要很长时间,但是在这段时间内是已经找到一些数据,我想在搜索其他数据的过程中把已经搜索到的数据显示出来,我用的是Literal。想问一下这样用什么方法实现是比较好的?现在看到CSDN的网页局部刷新输出很爽,自己就是做不出来啊!!! 我现在所做的一个东西是从网上搜索我需要的数据,然后显示到我本地的aspx页面上,由于数据量是比较大,现在我搜索的话需要很长时间,但是在这段时间内是已经找到一些数据,我想在搜索其他数据的过程中把已经搜索到的数据显示出来,我用的是Literal。想问一下这样用什么方法实现是比较好的?现在看到CSDN的网页局部刷新输出很爽,自己就是做不出来啊!!!=========================================看来你根本就没懂AJAX的含义啊……局部刷新出来的数据难道不是从逻辑层返回的数据? 这时间当然不会少,但是现在之前有一段假死状态,我想像CSDN一样先显示一部分,其他的再慢慢的输出,这样的页面不是更友好?还有我真的是不懂Ajax不是好像,我也是刚看的,但是不知道人家网页是怎么实现的,希望您能指正一下。谢谢!! 可参考http://topic.csdn.net/u/20101217/01/723B746E-A62E-408D-B76C-3800D8F9D05F.html 还有一个方法,就是jquery的loader方法,三个div的内容,写成三个aspx文件,然后在主页面通过jquery.Loader方法调用,如果在js里再加个定时,hoho。我不说了,你自己理解吧。哈哈对了,主页面里的div只要定义一个id,里面啥都不要写,jquery会帮你完成刷新的。哈哈------------------------------------------------------------------------------------------------概述载入远程 HTML 文件代码并插入至 DOM 中。默认使用 GET 方式 - 传递附加参数时自动转换为 POST 方式。jQuery 1.2 中,可以指定选择符,来筛选载入的 HTML 文档,DOM 中将仅插入筛选出的 HTML 代码。语法形如 "url #some > selector"。请查看示例。参数urlString待装入 HTML 网页网址。data (可选)Map,String发送至服务器的 key/value 数据。在jQuery 1.3中也可以接受一个字符串了。callback (可选)Callback载入成功时回调函数。示例描述:加载文章侧边栏导航部分至一个无序列表。HTML 代码:<b>jQuery Links:</b><ul id="links"></ul>jQuery 代码:$("#links").load("/Main_Page #p-Getting-Started li");描述:加载 feeds.html 文件内容。jQuery 代码:$("#feeds").load("feeds.html");描述:同上,但是以 POST 形式发送附加参数并在成功时显示信息。jQuery 代码: $("#feeds").load("feeds.php", {limit: 25}, function(){ alert("The last 25 entries in the feed have been loaded"); }); 如何在SQL SERVER中某字段追加一个值 后台怎么接收前台隐藏域里面的值 求问xpath高手. 这个查询怎么解决 TreeView数据绑定 复选框怎么获得ID值 高手帮忙。。 Cache如何保存TreeView????? 急!!!关于执行带参数的SQL语句的错误。 DropDownList关联不刷新问题! 新手问题:ASP.Net中怎样通过按钮提交一个表单? 后台如何给password控件赋值?急!! 模拟表单post已经成功,但如何提交一个以上的表单元素? 用DIV+CSS代替window.showModalDialog,如何返回值? asp.net易宝支付接口怎么用啊?
<ContentTemplate>
<div class="itemarea small l">
<span class="subtit">一级关键词</span>
<asp:Literal runat="server" ID="FirstKeyWordHTML"></asp:Literal>
</div>
</ContentTemplate>
</asp:UpdatePanel>你看是这种么???
<script runat="server"> protected void Timer1_Tick(object sender, EventArgs e)
{
if (!Panel1.Visible)
{
Panel1.Visible = true;
UpdatePanel2.Update();
}
else if (!Panel2.Visible)
{
Panel2.Visible = true;
UpdatePanel3.Update();
this.Calendar1.SelectedDate = new DateTime(2010, 10, 1);
}
else if (!Panel3.Visible)
{
Panel3.Visible = true;
UpdatePanel4.Update();
this.frame.Attributes["src"] = "http://topic.csdn.net/u/20101221/10/1d479fd6-9f09-41a7-bd8e-fc3fce352051.html?seed=1463094318&r=70713815#r_70713815";
}
else
this.Timer1.Enabled = false;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="100" OnTick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="Panel2" runat="server" Visible="false">
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="Panel3" runat="server" Visible="false">
<iframe id="frame" runat="server" width="100%" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Visible="false">
<asp:Image ID="Image1" runat="server" ImageUrl="http://imgsrc.soso.com/imgget.q?id=e422d6d9a9c9b462a61b5e9d37105d87" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
=========================================
看来你根本就没懂AJAX的含义啊……局部刷新出来的数据难道不是从逻辑层返回的数据?
http://topic.csdn.net/u/20101217/01/723B746E-A62E-408D-B76C-3800D8F9D05F.html
载入远程 HTML 文件代码并插入至 DOM 中。默认使用 GET 方式 - 传递附加参数时自动转换为 POST 方式。jQuery 1.2 中,可以指定选择符,来筛选载入的 HTML 文档,DOM 中将仅插入筛选出的 HTML 代码。语法形如 "url #some > selector"。请查看示例。参数
urlString待装入 HTML 网页网址。data (可选)Map,String发送至服务器的 key/value 数据。在jQuery 1.3中也可以接受一个字符串了。callback (可选)Callback载入成功时回调函数。示例
描述:
加载文章侧边栏导航部分至一个无序列表。HTML 代码:
<b>jQuery Links:</b>
<ul id="links"></ul>jQuery 代码:
$("#links").load("/Main_Page #p-Getting-Started li");描述:
加载 feeds.html 文件内容。jQuery 代码:
$("#feeds").load("feeds.html");描述:
同上,但是以 POST 形式发送附加参数并在成功时显示信息。jQuery 代码:
$("#feeds").load("feeds.php", {limit: 25}, function(){
alert("The last 25 entries in the feed have been loaded");
});