All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ms,sql,更新表A中某列为表B中的值_mssql学习_编程技术
不需要mod_rewrite直接使用php实现伪静态化页面_[PHP教程]
Asp.net,2.0,用C#,创建,PDF文件(示例代码下载)_[Asp.Net教程]
跟我学SQL:(三)使用SQL子选择来合并查询_mssql学习_编程技术
利用单元测试在每个层上对PHP代码进行检查_php资料_编程技术
C#中do while语句的使用实例详解
EditPlus+NAnt构建轻巧的.NET开发环境_[Asp.Net教程]
C#教程:电子邮件的接收使用实例
XSL JavaScript+XMLDOM的使用_[XML教程]
asp.net三种跳转页面的方法_[Asp.Net教程]
Reading number is top 10 pictures
西游四格漫画(六)
西班牙山村小景1
美洲杯宝贝的雨中风情1
贩卖儿童者必须判死刑
The world's top ten most beautiful railway station1
Exquisite decoration is not paying too much4
The Soviet union swimsuit exposure in the 70 year2
西班牙山村小景4
色狗系列
The money of more than 100 countries and regions19
Download software ranking
Wild things 2
Tram sex maniac 2 (H) rar bag15
jdk1.6 for windows
The Bermuda triangle1
Desire a peach blossom
美女写真1
传奇私服架设教程
Tram sex maniac 2 (H) rar bag17
双旗镇刀客A
电车之狼R
delv published in(发表于) 2014/1/6 9:10:30 Edit(编辑)
在ASP.NET,Atlas中创建自定义Action_[Asp.Net教程]

在ASP.NET,Atlas中创建自定义Action_[Asp.Net教程]

在ASP.NET Atlas中创建自定义Action_[Asp.Net教程]

Action是ASP.NET Atlas中继承于Sys.Action基类的的一类组件,用来实现一类由某个事件引发的事件处理功能。Action与事件处理函数的功能类似,但它是一类泛化了的事件处理组件,用来描述一些常见的,通用的事件处理方法,例如调用某个方法,设定某个对象的某个属性,引发一个PostBack等。

  我们都知道,目前为止,Atlas最好的参考手册就是它的源代码。我们可以从源代码中找到如下三种Atlas的内建Action,他们都继承于Sys.Action基类:

  Sys.InvokeMethodAction:用来调用一个指定的函数。

  Set.SetPropertyAction:用来设定某个对象的某个属性值。

  Sys.WebForms.PostBackAction:用来引发一个PostBack。

  在实际的项目中,仅仅使用以上三个内建的Action往往是不够的,我们通常会需要自己定义一些在项目中常用的Action。幸运的是,在Atlas完备的架构中,创建自定义的Action将是非常简单的事情。下面让我们通过一个简单的AlertAction示例来熟悉自定义Action的方法。当某个指定的事件被引发时,AlertAction将显示给用户一个JavaScript提示对话框,内含指定的文字。

  通常的,创建自定义的Action有如下四个步骤:

  继承于Sys.Action基类。

  定义您的Action类的属性。在AlertAction的示例中,我们需要指定一个message属性用来保存将要显示给用户的内容。

  实现performAction()方法,以执行您需要的自定义操作。这个方法将被Action基类自动调用。在我们的示例中,只是简单的使用JavaScript中的内建alert()函数来弹出对话框,并显示message属性中的内容。

  为您的自定义Action 在getDescriptor()方法中添加相关的类型说明。

  下面是AlertAction的JavaScript代码。上述四个步骤在代码内以注释的形式标出。将下面的代码保存为AlertAction.js。


Sys.AlertAction = function() {
Sys.AlertAction.initializeBase(this);

// step 2
var _message;

this.get_message = function() {
return _message;
}
this.set_message = function(value) {
_message = value;
}

// step 4
this.getDescriptor = function() {
var td = Sys.AlertAction.callBaseMethod(this, 'getDescriptor');

td.addProperty('message', String);
return td;
}

// step 3
this.performAction = function() {
alert(_message);
return null;
}
}
// step 1
Sys.AlertAction.registerSealedClass('Sys.AlertAction', Sys.Action);
Sys.TypeDescriptor.addType('script', 'alertAction', Sys.AlertAction);

  让我们在页面中测试一下这个AlertAction。这里需要在页面上添加的仅仅是一个Button,用来引发我们的AlertAction。下面是ASPX文件中的HTML定义。不要忘记在ScriptManager中添加对AlertAction.js文件的引用。


<atlas:ScriptManager EnablePartialRendering="true" ID="ScriptManager1" runat="server">
<Scripts>
<atlas:ScriptReference Path="AlertAction.js" />
</Scripts>
</atlas:ScriptManager>
<div>
<input id="myButton" type="button" value="Click Me!" />
</div>

  下面是Atlas脚本定义,十分简单,这里不再赘述。


<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<button id="myButton">
<click>
<alertAction message="Button Clicked!" />
</click>
</button>
</components>
</page>
</script>

  浏览器中的运行结果:




  上述示例程序可以在此下载:http://www.cnblogs.com/Files/dflying/AtlasActionDemo.zip
作者:dflying 来源:博客园





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.