该扩展的功能有以下几点:
1、当鼠标移到某个按钮上时,该按钮显示一个Css样式;
2、当鼠标移开该按钮时,该按钮显示另外一个Css样式;
3、当鼠标点击该按钮时,执行一个用户自己定义的javascript函数;
该extender共有以下三个文件:
HoverButtonExtender.cs
HoverButtonDesigner.cs
HoverButtonBehavior.js
其中HoverButtonDesigner.cs和HoverButtonBehavior.js的代码分别如下:
1
// (c) Copyright Microsoft Corporation.
2
// This source is subject to the Microsoft Permissive License.
3
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
4
// All other rights reserved.
5
6
7
// README
8
//
9
// There are two steps to adding a property:
10
//
11
// 1. Create a member variable to store your property
12
// 2. Add the get_ and set_ accessors for your property.
13
//
14
// Remember that both are case sensitive!
15
//
16
17
Type.registerNamespace('HoverButton');
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
这里注意一下第80行,window.setTimeout(this._OnButtonClickScript, 0); 这个_OnButtonClickScript是一个字符串,表示客户端页面上用户自己定义的一个函数的名字,通过这个语句就能够执行整个客户端函数。有了这样的机制,用户就能够自己定义按钮的响应函数了。
HoverButtonExtender.cs
该扩展的使用,代码如下:
1
希望能对您有帮助。