即将推出的ASP.NET Ajax Library...
有很久一段时间我的BLOG上没有出现AJAX相关讯息了,主要当然是因为绝大部分的重心都放到了Silverlight身上(可预期的未来应该也会是如此)。
但由于工作上的需要,最近还是回头看了一下即将推出的ASP.NET Ajax Library...,顺便找了一下网络上的讯息,看这个态势我猜想应该不少ASP.NET开发人员忽略掉了这个其实已经beta很久即将随着VS2010推出的JavaScript Library,当然,也可能是因为您已经在使用jQuery了。
不过仔细看看ASP.NET Ajax Library当中还是有不少精彩的功能,同时现在微软针对AJAX JavaScript Library也提供了CDN(content delivery network)服务,让您可以直接在页面上引用位于微软的javaScript档案,而不再需要把档案放在自己的项目中。
后面如果时间允许,我也会陆续介绍ASP.NET Ajax Library中的一些功能,以及和jQuery的整合方式。首先来看ASP.NET Ajax Library中Client Controls的使用(底下的范例是水印的TextBox):
<head>
<title>Untitled Page</title>
<style type="text/css">
.wm {
color:Gray
}
</style>
<!--從CDN引用js-->
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.js" type="text/javascript"></script>
<script src="http://ajax.microsoft.com/ajax/beta/0911/Start.debug.js" type="text/javascript"></script>
<script src="http://ajax.microsoft.com/ajax/beta/0911/extended/ExtendedControls.debug.js" type="text/javascript"></script>
<script type="text/javascript">
//建立watermark
Sys.require(Sys.components.watermark, function() {
$("#TextBoxName").watermark("<請輸入您的姓名>", "wm");
});
</script>
</head>
<body>
<input type="text" id="TextBoxName" size="50" /> //實際的TextBox
</body>
请注意上面这段脚本是HTML Code, 没有一丁点的ASP.NET Server Code, 单纯只是透过ASP.NET Ajax Library与JavaScript来呈现出水印的TextBox(其中还用到了一点点jQuery语法,最后呈现出的结果是:
回头看前面的HTML与JavaScript Code,这中间有相当多的新技术,包
相关文档:
<asp:TemplateField HeaderText="测试">
<ItemTemplate>
<asp:LinkButton ID="test" runat="server" OnClick="test_Click" OnClientClick='<%# string.Format("return confirmDelete(\"{0} {1}\");", DoEscape((string)Eval( ......
方法一:
HtmlProxy.cs:
using System.Text;
using System.IO;
/// <summary>
/// HtmlProxy 的摘要说明
/// </summary>
public class HtmlProxy
{
public HtmlProxy()
{
//
......
一、(单值绑定)在页面的后台代码中定义公有变量,如下:
public string gongYou = "声明的公有成员";
①然后在页面的源中调用,如下:
<asp:Label ID="lblMgs" runat="server" Text="<%#gongYou >"></asp:Label>
②当然最后要记得绑定数据:
protected void Page_Load(object ......
<script type="text/javascript">
var loginName,checkUN,password,confirmPwd,email,subBtn,userName,checkTel,tel;
$(init);
function init()
{
loginName = $("#loginName");
loginName.bind("blur",checkUserName);
password = $("#password"); ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class _Default : Syste ......