|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
HierarchicalDataSourceControl, classe
System.Web.UI.Control
System.Web.UI.HierarchicalDataSourceControl
System.Web.UI.WebControls.SiteMapDataSource
System.Web.UI.WebControls.XmlDataSource
Espace de noms : System.Web.UI
Assembly : System.Web (dans System.Web.dll)
Le type HierarchicalDataSourceControl expose les membres suivants.
| Nom | Description | |
|---|---|---|
![]() | HierarchicalDataSourceControl |
| Nom | Description | |
|---|---|---|
![]() | Adapter | |
![]() | AppRelativeTemplateSourceDirectory | |
![]() | BindingContainer | Infrastructure. |
![]() | ChildControlsCreated | |
![]() | ClientID | |
![]() | ClientIDMode | |
![]() | ClientIDSeparator | |
![]() | Context | |
![]() | Controls | |
![]() | DataItemContainer | |
![]() | DataKeysContainer | |
![]() | DesignMode | |
![]() | EnableTheming | |
![]() | EnableViewState | |
![]() | Events | |
![]() | HasChildViewState | |
![]() | ID | |
![]() | IdSeparator | Infrastructure. |
![]() | IsChildControlStateCleared | |
![]() | IsTrackingViewState | |
![]() | IsViewStateEnabled | |
![]() | LoadViewStateByID | |
![]() | NamingContainer | |
![]() | Page | |
![]() | Parent | |
![]() | RenderingCompatibility | |
![]() | Site | |
![]() | SkinID | |
![]() | TemplateControl | |
![]() | TemplateSourceDirectory | |
![]() | UniqueID | |
![]() | ValidateRequestMode | |
![]() | ViewState | |
![]() | ViewStateIgnoresCase | |
![]() | ViewStateMode | |
![]() | Visible |
| Nom | Description | |
|---|---|---|
![]() | AddedControl | |
![]() | AddParsedSubObject | |
![]() | ApplyStyleSheetSkin | |
![]() | BeginRenderTracing | |
![]() | BuildProfileTree | Infrastructure. |
![]() | ClearCachedClientID | Infrastructure. |
![]() | ClearChildControlState | |
![]() | ClearChildState | |
![]() | ClearChildViewState | |
![]() | ClearEffectiveClientIDMode | Infrastructure. |
![]() | CreateChildControls | |
![]() | CreateControlCollection | |
![]() | DataBind() | |
![]() | DataBind(Boolean) | |
![]() | DataBindChildren | |
![]() | Dispose | |
![]() | EndRenderTracing | |
![]() | EnsureChildControls | |
![]() | EnsureID | |
![]() | Equals(Object) | |
![]() | Finalize | |
![]() | FindControl(String) | |
![]() | FindControl(String, Int32) | Infrastructure. |
![]() | Focus | |
![]() | GetDesignModeState | Infrastructure. |
![]() | GetHashCode | |
![]() | GetHierarchicalView | |
![]() | GetRouteUrl(Object) | |
![]() | GetRouteUrl(RouteValueDictionary) | |
![]() | GetRouteUrl(String, Object) | |
![]() | GetRouteUrl(String, RouteValueDictionary) | |
![]() | GetType | |
![]() | GetUniqueIDRelativeTo | |
![]() | HasControls | |
![]() | HasEvents | |
![]() | IsLiteralContent | Infrastructure. |
![]() | LoadControlState | |
![]() | LoadViewState | |
![]() | MapPathSecure | |
![]() | MemberwiseClone | |
![]() | OnBubbleEvent | |
![]() | OnDataBinding | |
![]() | OnDataSourceChanged | |
![]() | OnInit | |
![]() | OnLoad | |
![]() | OnPreRender | |
![]() | OnUnload | |
![]() | OpenFile | |
![]() | RaiseBubbleEvent | |
![]() | RemovedControl | |
![]() | Render | |
![]() | RenderChildren | |
![]() | RenderControl(HtmlTextWriter) | |
![]() | RenderControl(HtmlTextWriter, ControlAdapter) | |
![]() | ResolveAdapter | |
![]() | ResolveClientUrl | |
![]() | ResolveUrl | |
![]() | SaveControlState | |
![]() | SaveViewState | |
![]() | SetDesignModeState | |
![]() | SetRenderMethodDelegate | Infrastructure. |
![]() | SetTraceData(Object, Object) | |
![]() | SetTraceData(Object, Object, Object) | |
![]() | ToString | |
![]() | TrackViewState |
| Nom | Description | |
|---|---|---|
![]() | DataBinding | |
![]() | Disposed | |
![]() | Init | |
![]() | Load | |
![]() | PreRender | |
![]() | Unload |
| Nom | Description | |
|---|---|---|
![]() | FindDataSourceControl | |
![]() | FindFieldTemplate | |
![]() | FindMetaTable |
| Nom | Description | |
|---|---|---|
![]() ![]() | IControlBuilderAccessor.ControlBuilder | |
![]() ![]() | IControlDesignerAccessor.GetDesignModeState | |
![]() ![]() | IControlDesignerAccessor.SetDesignModeState | |
![]() ![]() | IControlDesignerAccessor.SetOwnerControl | Infrastructure. |
![]() ![]() | IControlDesignerAccessor.UserData | |
![]() ![]() | IDataBindingsAccessor.DataBindings | |
![]() ![]() | IDataBindingsAccessor.HasDataBindings | |
![]() ![]() | IExpressionsAccessor.Expressions | |
![]() ![]() | IExpressionsAccessor.HasExpressions | |
![]() ![]() | IHierarchicalDataSource.DataSourceChanged | Infrastructure. |
![]() ![]() | IHierarchicalDataSource.GetHierarchicalView | Infrastructure. |
![]() ![]() | IParserAccessor.AddParsedSubObject |
using System; using System.Collections; using System.IO; using System.Runtime.InteropServices; using System.Security.Permissions; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public class FileSystemDataSource : HierarchicalDataSourceControl, IHierarchicalDataSource { private FileSystemDataSourceView view = null; public FileSystemDataSource() : base() { } protected override HierarchicalDataSourceView GetHierarchicalView(string viewPath) { view = new FileSystemDataSourceView(viewPath); return view; } } public class FileSystemDataSourceView : HierarchicalDataSourceView { private string _viewPath; public FileSystemDataSourceView(string viewPath) { HttpRequest currentRequest = HttpContext.Current.Request; if (viewPath == "") { _viewPath = currentRequest.MapPath(currentRequest.ApplicationPath); } else { _viewPath = Path.Combine( currentRequest.MapPath(currentRequest.ApplicationPath), viewPath); } } // Starting with the rootNode, recursively build a list of // FileSystemInfo nodes, create FileSystemHierarchyData // objects, add them all to the FileSystemHierarchicalEnumerable, // and return the list. public override IHierarchicalEnumerable Select() { HttpRequest currentRequest = HttpContext.Current.Request; // SECURITY: There are many security issues that can be raised // SECURITY: by exposing the file system structure of a Web server // SECURITY: to an anonymous user in a limited trust scenario such as // SECURITY: a Web page served on an intranet or the Internet. // SECURITY: For this reason, the FileSystemDataSource only // SECURITY: shows data when the HttpRequest is received // SECURITY: from a local Web server. In addition, the data source // SECURITY: does not display data to anonymous users. if (currentRequest.IsAuthenticated && (currentRequest.UserHostAddress == "127.0.0.1" || currentRequest.UserHostAddress == "::1")) { DirectoryInfo rootDirectory = new DirectoryInfo(_viewPath); if (!rootDirectory.Exists) { return null; } FileSystemHierarchicalEnumerable fshe = new FileSystemHierarchicalEnumerable(); foreach (FileSystemInfo fsi in rootDirectory.GetFileSystemInfos()) { fshe.Add(new FileSystemHierarchyData(fsi)); } return fshe; } else { throw new NotSupportedException( "The FileSystemDataSource only " + "presents data in an authenticated, localhost context."); } } } // A collection of FileSystemHierarchyData objects public class FileSystemHierarchicalEnumerable : ArrayList, IHierarchicalEnumerable { public FileSystemHierarchicalEnumerable() : base() { } public IHierarchyData GetHierarchyData(object enumeratedItem) { return enumeratedItem as IHierarchyData; } } public class FileSystemHierarchyData : IHierarchyData { private FileSystemInfo fileSystemObject = null; public FileSystemHierarchyData(FileSystemInfo obj) { fileSystemObject = obj; } public override string ToString() { return fileSystemObject.Name; } // IHierarchyData implementation. public bool HasChildren { get { if (typeof(DirectoryInfo) == fileSystemObject.GetType()) { DirectoryInfo temp = (DirectoryInfo)fileSystemObject; return (temp.GetFileSystemInfos().Length > 0); } else return false; } } // DirectoryInfo returns the OriginalPath, while FileInfo returns // a fully qualified path. public string Path { get { return fileSystemObject.ToString(); } } public object Item { get { return fileSystemObject; } } public string Type { get { return "FileSystemData"; } } public IHierarchicalEnumerable GetChildren() { FileSystemHierarchicalEnumerable children = new FileSystemHierarchicalEnumerable(); if (typeof(DirectoryInfo) == fileSystemObject.GetType()) { DirectoryInfo temp = (DirectoryInfo)fileSystemObject; foreach (FileSystemInfo fsi in temp.GetFileSystemInfos()) { children.Add(new FileSystemHierarchyData(fsi)); } } return children; } public IHierarchyData GetParent() { FileSystemHierarchicalEnumerable parentContainer = new FileSystemHierarchicalEnumerable(); if (typeof(DirectoryInfo) == fileSystemObject.GetType()) { DirectoryInfo temp = (DirectoryInfo)fileSystemObject; return new FileSystemHierarchyData(temp.Parent); } else if (typeof(FileInfo) == fileSystemObject.GetType()) { FileInfo temp = (FileInfo)fileSystemObject; return new FileSystemHierarchyData(temp.Directory); } // If FileSystemObj is any other kind of FileSystemInfo, ignore it. return null; } }
<%@ Page Language="C#" %> <%@ Register Tagprefix="aspSample" Namespace="Samples.AspNet" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>ASP.NET Example</title> </head> <body> <form id="form1" runat="server"> <asp:treeview id="TreeView1" runat="server" datasourceid="FileSystemDataSource1" /> <aspSample:filesystemdatasource id = "FileSystemDataSource1" runat = "server" /> </form> </body> </html>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.


