Third,C#
Ajax:
需要以下技术:
DHtml:
DHTML是Dynamic HTML的简称,就是动态的html(标准通用标记语言下的一个应用),是相对传统的静态的html而言的一种制作网页的概念。所谓动态HTML(Dynamic HTML,简称DHTML),其实并不是一门新的语言,它只是HTML、CSS和客户端脚本的一种集成,即一个页面中包括html+css+javascript(或其它客户端脚本),其中css和客户端脚本是直接在页面上写而不是链接上相关文件。DHTML不是一种技术、标准或规范,只是一种将目前已有的网页技术、语言标准整合运用,制作出能在下载后仍然能实时变换页面元素效果的网页设计概念。
javascript: 在Dhtml中访问Dom
XmlhttpRequest:
这个对象用于从javaScript中进行异步调用,向服务器请求额外的数据。
XHR英文全名XmlHttpRequest,中文可以解释为可扩展超文本传输请求。Xml可扩展标记语言,Http超文本传输协议,Request请求。XMLHttpRequest对象可以在不向服务器提交整个页面的情况下,实现局部更新网页。当页面全部加载完毕后,客户端通过该对象向服务器请求数据,服务器端接受数据并处理后,向客户端反馈数据。 XMLHttpRequest 对象提供了对 HTTP 协议的完全的访问,包括做出 POST 和 HEAD 请求以及普通的 GET 请求的能力。XMLHttpRequest 可以同步或异步返回 Web 服务器的响应,并且能以文本或者一个 DOM 文档形式返回内容。尽管名为 XMLHttpRequest,它并不限于和 XML 文档一起使用:它可以接收任何形式的文本文档。XMLHttpRequest 对象是名为 AJAX 的 Web 应用程序架构的一项关键功能。
Json:
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。它基于ECMAScript的一个子集。 JSON采用完全独立于语言的文本格式,但是也使用了类似于C语言家族的习惯(包括C、C++、C#、Java、JavaScript、Perl、Python等)。这些特性使JSON成为理想的数据交换语言。 易于人阅读和编写,同时也易于机器解析和生成(一般用于提升网络传输速率)。
such as:
使用UpdatePanel,ScriptManager
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" ></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode ="Conditional"><ContentTemplate >
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><asp:Button ID="Button1" runat="server" Text="Buttona" OnClick="Button1_Click" /></ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode ="Conditional"><ContentTemplate>
<asp:Button ID="Button2" runat="server" Text="Buttonb" OnClick="Button1_Click" /><asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></ContentTemplate></asp:UpdatePanel>
</div>
</form>
Label1 .Text = Convert.ToString(DateTime.Now.ToLocalTime().AddHours(1));
Label2 .Text = DateTime.Now.ToLongTimeString();
2。
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"></asp:Timer>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</form>
protected void Timer1_Tick(object sender, EventArgs e)
{
// Label1.Text = DateTime.Now.ToLongTimeString();
Label2.Text = DateTime.Now.ToLongTimeString();
}
web服务:
<script type ="text/javascript" > var helloService; function b() { alert(5);} function pageLoad() { //alert(1); //debugger; helloService = new HelloService(); helloService.set_defaultSucceededCallback(hellosucceed); helloService.set_defaultFailedCallback(helloFailed); } function a() { alert(4); } function hellosucceed(result) { debugger; alert(2) var d = document.getElementById("result"); d.innerHTML = result; } function helloFailed(error, userContext, methodName) { alert(3); debugger; } function callService() { alert(6); debugger; var l = document.getElementById("Text1"); helloService.Greeting(l.value,hellosucceed ); //或helloService.Greeting (1.value,hellosucced,helloFailed); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="../HelloService.svc" /> </Services> </asp:ScriptManager> </div> <div> <%-- <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate > <asp:Button runat="server" Text="Button ajax" OnClick="Unnamed1_Click" /> <asp:Label runat="server" Text="Label" ID="lbajax"></asp:Label> </ContentTemplate> </asp:UpdatePanel>--%> <input id="Button1" type="button" value="service" onclick="callService()"/> <input id="Text1" type="text" /> <div id="result"> </div> </div> </form>
[ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class HelloService { // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json) // To create an operation that returns XML, // add [WebGet(ResponseFormat=WebMessageFormat.Xml)], // and include the following line in the operation body: // WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml"; [WebGet] [OperationContract] public string Greeting(string name) { return "Hello, " + name; } [OperationContract] public void DoWork() { // Add your operation implementation here return; } // Add more operations here and mark them with [OperationContract] }
浙公网安备 33010602011771号