📄 cascadingdropdownextender.cs
字号:
// (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.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
#region Assembly Resource Attribute
[assembly: System.Web.UI.WebResource("AjaxControlToolkit.CascadingDropDown.CascadingDropDownBehavior.js", "text/javascript")]
#endregion
namespace AjaxControlToolkit
{
/// <summary>
/// CascadingDropDown extender class definition
/// </summary>
[Designer("AjaxControlToolkit.CascadingDropDownDesigner, AjaxControlToolkit")]
[ClientScriptResource("AjaxControlToolkit.CascadingDropDownBehavior", "AjaxControlToolkit.CascadingDropDown.CascadingDropDownBehavior.js")]
[RequiredScript(typeof(CommonToolkitScripts))]
[TargetControlType(typeof(DropDownList))]
[System.Drawing.ToolboxBitmap(typeof(CascadingDropDown), "CascadingDropDown.CascadingDropDown.ico")]
public class CascadingDropDown : ExtenderControlBase
{
/// <summary>
/// Constructor
/// </summary>
public CascadingDropDown()
{
ClientStateValuesLoaded += new EventHandler(CascadingDropDown_ClientStateValuesLoaded);
EnableClientState = true;
}
/// <summary>
/// Optional ID of the parent DropDownList (upon which the contents of this control are based)
/// </summary>
[IDReferenceProperty(typeof(DropDownList))]
[DefaultValue("")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase", Justification = "Following ASP.NET AJAX pattern")]
[ExtenderControlProperty()]
public string ParentControlID
{
get { return GetPropertyValue<string>("ParentControlID", ""); }
set { SetPropertyValue<string>("ParentControlID", value); }
}
/// <summary>
/// Category of this DropDownList (used when communicating with the helper web service)
/// </summary>
[RequiredProperty()]
[DefaultValue("")]
[ExtenderControlProperty()]
public string Category
{
get { return GetPropertyValue<string>("Category", ""); }
set { SetPropertyValue<string>("Category", value); }
}
/// <summary>
/// Optional text displayed by a DropDownList the user has not yet touched.
/// If omitted, first item in the dropdown is selected
/// </summary>
[DefaultValue("")]
[ExtenderControlProperty()]
public string PromptText
{
get { return GetPropertyValue<string>("PromptText", ""); }
set { SetPropertyValue<string>("PromptText", value); }
}
/// <summary>
/// Optional value for the option displayed by a DropDownList showing the PromptText
/// </summary>
[DefaultValue("")]
[ExtenderControlProperty()]
public string PromptValue
{
get { return GetPropertyValue<string>("PromptValue", ""); }
set { SetPropertyValue<string>("PromptValue", value); }
}
/// <summary>
/// Optional text for the option displayed when the list is empty
/// </summary>
[DefaultValue("")]
[ExtenderControlProperty()]
public string EmptyText
{
get { return GetPropertyValue<string>("EmptyText", ""); }
set { SetPropertyValue<string>("EmptyText", value); }
}
/// <summary>
/// Optional value for the option displayed when the list is empty
/// </summary>
[DefaultValue("")]
[ExtenderControlProperty()]
public string EmptyValue
{
get { return GetPropertyValue<string>("EmptyValue", ""); }
set { SetPropertyValue<string>("EmptyValue", value); }
}
/// <summary>
/// Optional text displayed by a DropDownList when it is loading its data
/// </summary>
[DefaultValue("")]
[ExtenderControlProperty()]
public string LoadingText
{
get { return GetPropertyValue<string>("LoadingText", ""); }
set { SetPropertyValue<string>("LoadingText", value); }
}
/// <summary>
/// Selected value of the drop down
/// </summary>
[DefaultValue("")]
[ExtenderControlProperty()]
public string SelectedValue
{
get { return ClientState ?? ""; }
set { ClientState = value; }
}
/// <summary>
/// Path to the helper web service
/// </summary>
[UrlProperty()]
[ExtenderControlProperty()]
[TypeConverter(typeof(ServicePathConverter))]
public string ServicePath
{
get { return GetPropertyValue<string>("ServicePath", ""); }
set { SetPropertyValue<string>("ServicePath", value); }
}
/// <summary>
/// Prevent the service path from being serialized when it's empty
/// </summary>
/// <returns>Whether the service path should be serialized</returns>
private bool ShouldSerializeServicePath()
{
return !string.IsNullOrEmpty(ServiceMethod);
}
/// <summary>
/// Name of the web service method
/// </summary>
[RequiredProperty()]
[DefaultValue("")]
[ExtenderControlProperty()]
public string ServiceMethod
{
get { return GetPropertyValue<string>("ServiceMethod", ""); }
set { SetPropertyValue<string>("ServiceMethod", value); }
}
/// <summary>
/// User/page specific context provided to an optional overload of the
/// web method described by ServiceMethod/ServicePath. If the context
/// key is used, it should have the same signature with an additional
/// parameter named contextKey of type string.
/// </summary>
[ExtenderControlProperty]
[ClientPropertyName("contextKey")]
[DefaultValue(null)]
public string ContextKey
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -