📄 basenavigator.cs
字号:
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
namespace ComponentArt.Web.UI
{
#region Template Classes
/// <summary>
/// NavigationCustomTemplate class.
/// </summary>
[
ToolboxItem(false),
DefaultProperty("Template"),
ParseChildren(true),
PersistChildren(false)
]
public class NavigationCustomTemplate : System.Web.UI.WebControls.WebControl
{
private ITemplate m_oTemplate;
/// <summary>
/// The template.
/// </summary>
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(ComponentArt.Web.UI.NavigationTemplateContainer)),
NotifyParentProperty(true)
]
public virtual ITemplate Template
{
get
{
return m_oTemplate;
}
set
{
m_oTemplate = value;
}
}
}
/// <summary>
/// NavigationTemplateContainer class.
/// </summary>
[ToolboxItem(false)]
public class NavigationTemplateContainer : Control, INamingContainer
{
private NavigationNode _dataItem;
private System.Web.UI.AttributeCollection _attributes;
/// <summary>
/// NavigationTemplateContainer constructor.
/// </summary>
/// <param name="oNode">Node to look to for data.</param>
public NavigationTemplateContainer(NavigationNode oNode)
{
_dataItem = oNode;
if(oNode != null)
{
_attributes = oNode.Attributes;
}
}
/// <summary>
/// Item containing data to bind to (a NavigationNode).
/// </summary>
public virtual NavigationNode DataItem
{
get
{
return _dataItem;
}
}
/// <summary>
/// Attributes of the given data item.
/// </summary>
public virtual System.Web.UI.AttributeCollection Attributes
{
get
{
return _attributes;
}
}
}
#endregion
#region Custom Attribute Classes
/// <summary>
/// Used for extending the data model of all ComponentArt navigation controls. Any number of custom XML attributes can be defined within the XML structure. These custom attributes can be mapped to navigation node properties via CustomAttributeMappings.
/// </summary>
[ToolboxItem(false)]
public class CustomAttributeMapping
{
private string _from;
private string _to;
/// <summary>
/// Name to map from.
/// </summary>
public string From
{
get
{
return _from;
}
set
{
_from = value;
}
}
/// <summary>
/// Name to map to.
/// </summary>
public string To
{
get
{
return _to;
}
set
{
_to = value;
}
}
}
/// <summary>
/// Collection of CustomAttributeMapping objects.
/// </summary>
[ToolboxItem(false)]
[Editor("System.Windows.Forms.Design.CollectionEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing")]
public class CustomAttributeMappingCollection : ICollection, IEnumerable, IList
{
private ArrayList _mappings;
public CustomAttributeMappingCollection()
{
_mappings = new ArrayList();
}
object IList.this[int index]
{
get
{
return _mappings[index];
}
set
{
_mappings[index] = (CustomAttributeMapping)value;
}
}
public int Count
{
get
{
return _mappings.Count;
}
}
public bool IsSynchronized
{
get
{
return true;
}
}
public object SyncRoot
{
get
{
return _mappings.SyncRoot;
}
}
public void CopyTo (Array ar, int index)
{
}
public virtual CustomAttributeMapping this[int index]
{
get
{
return (CustomAttributeMapping) _mappings[index];
}
set
{
_mappings[index] = value;
}
}
public void Remove (object item)
{
_mappings.Remove (item);
}
public void Insert (int index, object item)
{
_mappings[index] = item;
}
public int Add (object item)
{
return _mappings.Add(item);
}
public void Clear()
{
_mappings.Clear();
}
public bool Contains(object item)
{
return _mappings.Contains(item);
}
public int IndexOf (object item)
{
return _mappings.IndexOf(item);
}
public bool IsFixedSize
{
get
{
return false;
}
}
public bool IsReadOnly
{
get
{
return false;
}
}
public void RemoveAt(int index)
{
_mappings.RemoveAt(index);
}
public virtual IEnumerator GetEnumerator()
{
return _mappings.GetEnumerator();
}
}
#endregion
/// <summary>
/// Provides base navigation object model, data binding, template collections, selected node functionality, URL redirects, postbacks, navigation methods, and search engine structure rendering to its descendents. All ComponentArt navigation controls inherit from this class.
/// </summary>
public abstract class BaseNavigator : WebControl, INamingContainer, IPostBackEventHandler
{
protected bool bNewDataLoaded = false;
protected string selectedNodePostbackId;
protected bool renderDefaultStyles = false;
#region Public Properties
#region Unused hidden inheritance
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public override FontInfo Font
{
get { return base.Font; }
}
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public override string AccessKey
{
get { return base.AccessKey; }
}
#endregion
/// <summary>
/// Whether to perform a postback when a node is selected. Default: false.
/// </summary>
[Category("Behavior")]
[Description("Whether to perform a postback when a node is selected. Default: false.")]
[DefaultValue(false)]
public bool AutoPostBackOnSelect
{
get
{
object o = ViewState["AutoPostBackOnSelect"];
return (o == null) ? false : (bool) o;
}
set
{
ViewState["AutoPostBackOnSelect"] = value;
}
}
/// <summary>
/// Prefix to use for all non-image URL paths. For images, use ImagesBaseUrl.
/// </summary>
[Category("Navigation")]
[Description("Used as a prefix for all node URLs. ")]
[DefaultValue("")]
public string BaseUrl
{
get
{
object o = ViewState["BaseUrl"];
return (o == null) ? String.Empty : Utils.ConvertUrl(Context, string.Empty, (string)o);
}
set
{
ViewState["BaseUrl"] = value;
}
}
/// <summary>
/// Whether to trigger ASP.NET page validation when a node is selected. Default: true.
/// </summary>
[Category("Behavior")]
[Description("Whether to trigger ASP.NET page validation when a node is selected. Default: true. ")]
[DefaultValue(true)]
public bool CausesValidation
{
get
{
object o = ViewState["CausesValidation"];
return (o == null) ? true : (bool) o;
}
set
{
ViewState["CausesValidation"] = value;
}
}
internal JavaScriptArray _clientTemplates = new JavaScriptArray();
/// <summary>
/// Collection of client-templates that may be used by this control.
/// </summary>
[Browsable(false)]
[Description("Collection of client-templates that may be used by this control.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public ArrayList ClientTemplates
{
get
{
return (ArrayList)_clientTemplates;
}
}
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
private CustomAttributeMappingCollection _customAttributeMappings;
/// <summary>
/// Custom attribute mappings. Provides the ability to re-map property names when they are looked up in XML.
/// </summary>
[Category("Data")]
[Description("Custom attribute mappings. Provides the ability to re-map property names when they are looked up in XML.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[NotifyParentProperty(true)]
public CustomAttributeMappingCollection CustomAttributeMappings
{
get
{
if(_customAttributeMappings == null)
{
_customAttributeMappings = new CustomAttributeMappingCollection();
}
return _customAttributeMappings;
}
}
private ControlCollection _serverTemplates;
/// <summary>
/// Custom server templates which are referenced by nodes with special needs.
/// </summary>
/// <seealso cref="NavigationNode.ServerTemplateId" />
[Browsable(false)]
[Description("Collection of CustomTemplate controls.")]
[PersistenceMode(PersistenceMode.InnerProperty)]
public ControlCollection ServerTemplates
{
get
{
if(_serverTemplates == null)
{
_serverTemplates = new ControlCollection(this);
}
return _serverTemplates;
}
}
/// <summary>
/// Custom server templates which are referenced by nodes with special needs.
/// </summary>
/// <remarks>
/// Deprecated. Use <see cref="ServerTemplates"/> instead.
/// </remarks>
/// <seealso cref="ServerTemplates" />
[Browsable(false)]
[Description("Deprecated. Use ServerTemplates instead.")]
//[PersistenceMode(PersistenceMode.InnerProperty)]
public ControlCollection Templates
{
get
{
return ServerTemplates;
}
}
private object _dataSource;
/// <summary>
/// DataSource to bind to. This can be an XmlDocument or a DataSet.
/// </summary>
/// <seealso cref="SiteMapXmlFile"/>
/// <seealso cref="LoadXml"/>
[
Browsable(false),
Description("Data source for ASP.NET data binding. "),
DefaultValue(null),
Category("Data")
]
public object DataSource
{
get
{
return _dataSource;
}
set
{
if (value == null || value is DataSet || value is XmlDocument)
_dataSource = value;
else
throw new ArgumentException("DataSource must be of type DataSet or XmlDocument.");
}
}
/// <summary>
/// The ID of the data source control to bind to. The control can be a SiteMapDataSource or XmlDataSource.
/// </summary>
[IDReferenceProperty(typeof(HierarchicalDataSourceControl))]
[Description("The ID of the data source control to bind to.")]
[DefaultValue("")]
[Category("Data")]
public string DataSourceID
{
get
{
object o = ViewState["DataSourceID"];
return (o == null) ? String.Empty : (string)o;
}
set
{
ViewState["DataSourceID"] = value;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -