当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 实现web页面的局部刷新

ASP.NET
Web服务器控件:LinkButton控件
Web服务器控件:ListBox控件
Web服务器控件:ListItem控件
Web服务器控件:Literal控件
Web服务器控件:Panel控件
Web服务器控件:PlaceHolder控件
Web服务器控件:RadioButton控件
Web服务器控件:RadioButtonList控件
Web服务器控件:BulletedList控件
Web服务器控件:Style控件
Web服务器控件:Table控件
Web服务器控件:TableCell控件
Web服务器控件:TableRow控件
Web服务器控件:TextBox控件
Web服务器控件:XML控件
Validation服务器控件:CompareValidator控件
Validation服务器控件:CustomValidator控件
Validation服务器控件:RangeValidator控件
Validation服务器控件:RegularExpressionValidator控件
Validation服务器控件:RequiredFieldValidator控件

ASP.NET 中的 实现web页面的局部刷新


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 175 ::
收藏到网摘: n/a


服务器的回传会引发整个页面的刷新,怎么样只让它刷新局部呢,前几天看见书上有讲用

WebService行为的,今天试了试,效果还不错

在web目录中需要一个文件webservice.htc

可以到这里下载: http://msdn.microsoft.com/workshop/author/webservice/webservice.htc

见一个WebService 文件名为Service1.asmx:

[WebService(Namespace="http://localhost/BehaviorService/")]
public class TestService : System.Web.Services.WebService
{

///
/// 返回服务器的时间
///

[WebMethod]
public string GetServerTime()
{
return DateTime.Now.ToString();
}
}

在同级目录下进一个html文件,内容如下:










我查看http://localhost/BehaviorService/test1.htm就可以看到一个服务器上的时间了而且是会动的,通过这种方法就可以实现页面的局部刷新了有两点限制:1.行为只能用域内的web服务,因为DHTML内置的安全限制造成的2.通过的这种方式的访问的类型会被限制,行为支持.net的基本类型和它们的数组如:dataset,datatable得复杂类型就不支持了