日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

ASP.NET AJAX 控件开发基础

發布時間:2023/12/4 asp.net 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ASP.NET AJAX 控件开发基础 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在 JavaScript 當前廣泛使用的版本中,它缺少 .NET 開發人員所熟悉的幾個 OOP 的關鍵概念,而 ASP.NET AJAX 可以模擬其中的大多數,而且 ASP.NET AJAX 的目標是將使用 .NET 的開發人員所熟悉的某些其他構造(例如屬性、事件、枚舉和接口)轉換成 JavaScript.ASP.NET AJAX 中的反射 API 將檢查所有類型(無論是內置類型、類、接口、命名空間、或者甚至是枚舉),而它們包括的類似 .NET Framework 的函數(例如 isInstanceOfType 和 inheritsFrom)可以在運行時檢查類的層次結構。

下面是一個典型的AjaxControlToolkit的控件腳本,紅色部分為添加的解釋語句:

// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

Type.registerNamespace('AjaxControlToolkit');?? //定義命名空間

//在 ASP.NET AJAX 中定義類,您需要將其構造函數賦給變量(注意,構造函數如何調用基礎函數):

AjaxControlToolkit.ConfirmButtonBehavior = function(element) {
/// <summary>
/// The ConfirmButtonBehavior extends buttons by providing a confirmation dialog when clicked
/// </summary>
/// <param name="element" type="Sys.UI.DomElement" domElement="true">
/// Button the behavior is associated with
/// </param>

//調用初始化基類,類似于C++/C# base關鍵字
AjaxControlToolkit.ConfirmButtonBehavior.initializeBase(this, [element]);

// Confirm text
this._ConfirmTextValue = null;
// Click handler for the target control
this._clickHandler = null;
}

//通過prototype定義成員()
AjaxControlToolkit.ConfirmButtonBehavior.prototype = {

//初始化資源
initialize : function() {
/// <summary>
/// Initialize the behavior
/// </summary>
AjaxControlToolkit.ConfirmButtonBehavior.callBaseMethod(this, 'initialize');
// Attach the handler
this._clickHandler = Function.createDelegate(this, this._onClick);
$addHandler(this.get_element(), "click", this._clickHandler);
},

//釋放資源

dispose : function() {
/// <summary>
/// Dispose the behavior
/// </summary>

// Detach event handlers
if (this._clickHandler) {
$removeHandler(this.get_element(), "click", this._clickHandler);
this._clickHandler = null;
}

AjaxControlToolkit.ConfirmButtonBehavior.callBaseMethod(this, 'dispose');
},

_onClick : function(e) {
/// <summary>
/// Button's click handler to display the confirmation dialog
/// </summary>
/// <param name="e" type="Sys.UI.DomEvent">
/// Event info
/// </param>

if (this.get_element() && !this.get_element().disabled) {
// Display confirm dialog and return result to allow cancellation
if (!window.confirm(this._ConfirmTextValue)) {
e.preventDefault();
return false;
}
}
},

get_ConfirmText : function() {
/// <value type="String">
/// The text to show when you want to confirm the click. (Note: HTML entities can be used here (ex: "&#10;" for new-line))
/// </value>
return this._ConfirmTextValue;
},
set_ConfirmText : function(value) {
if (this._ConfirmTextValue != value) {
this._ConfirmTextValue = value;
this.raisePropertyChanged('ConfirmText');
}
}
}

//最終注冊類:
AjaxControlToolkit.ConfirmButtonBehavior.registerClass('AjaxControlToolkit.ConfirmButtonBehavior', AjaxControlToolkit.BehaviorBase);

?

參考:[ASP.NET AJAX]類似.NET框架的JavaScript擴展

總結

以上是生活随笔為你收集整理的ASP.NET AJAX 控件开发基础的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。