SiteMapPath.NodeTemplate Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit un modèle de contrôle à utiliser pour l'ensemble des nœuds fonctionnels d'un chemin de navigation de site.
public:
virtual property System::Web::UI::ITemplate ^ NodeTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.SiteMapNodeItem))]
public virtual System.Web.UI.ITemplate NodeTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.SiteMapNodeItem))>]
member this.NodeTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property NodeTemplate As ITemplate
Valeur de propriété
Un objet ITemplate implémentant la méthode InstantiateIn(Control) afin d'afficher le contenu personnalisé de chaque nœud d'un chemin de navigation.
- Attributs
Exemples
L’exemple de code suivant montre comment un , lorsqu’un NodeTemplatenœud est spécifié, remplace les styles définis pour tous les nœuds, y compris les styles spéciaux pour le nœud racine et le nœud actuel.
Important
Cet exemple comprend une zone de texte qui accepte une entrée d'utilisateur, ce qui constitue une menace potentielle pour la sécurité. Par défaut, les pages web ASP.NET vérifient que l’entrée d’utilisateur n’inclut pas de script ou d’éléments HTML. Pour plus d’informations, consultez Vue d’ensemble des attaques de script.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="Form1" runat="server">
<!-- The following example demonstrates some of the orders
of precedence when applying styles and templates to
functional nodes of a SiteMapPath.
A NodeStyle, RootNodeStyle, and CurrentNodeStyle are
all defined. However, so is a NodeTemplate. The template
is applied to all nodes, and the styles ignored. -->
<asp:SiteMapPath ID="SiteMapPath1" runat="server"
RenderCurrentNodeAsLink="true"
NodeStyle-Font-Names="Franklin Gothic Medium"
NodeStyle-Font-Underline="true"
NodeStyle-Font-Bold="true"
RootNodeStyle-Font-Names="Symbol"
RootNodeStyle-Font-Bold="false"
CurrentNodeStyle-Font-Names="Verdana"
CurrentNodeStyle-Font-Size="10pt"
CurrentNodeStyle-Font-Bold="true"
CurrentNodeStyle-ForeColor="red"
CurrentNodeStyle-Font-Underline="false">
<NODETEMPLATE>
<asp:CheckBox id="CheckBox1" runat="server" Checked="true" />
<asp:TextBox id="TextBox1" runat="server" Text="Declarative template" />
</NODETEMPLATE>
</asp:SiteMapPath>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="Form1" runat="server">
<!-- The following example demonstrates some of the orders
of precedence when applying styles and templates to
functional nodes of a SiteMapPath.
A NodeStyle, RootNodeStyle, and CurrentNodeStyle are
all defined. However, so is a NodeTemplate. The template
is applied to all nodes, and the styles ignored. -->
<asp:SiteMapPath ID="SiteMapPath1" runat="server"
RenderCurrentNodeAsLink="true"
NodeStyle-Font-Names="Franklin Gothic Medium"
NodeStyle-Font-Underline="true"
NodeStyle-Font-Bold="true"
RootNodeStyle-Font-Names="Symbol"
RootNodeStyle-Font-Bold="false"
CurrentNodeStyle-Font-Names="Verdana"
CurrentNodeStyle-Font-Size="10pt"
CurrentNodeStyle-Font-Bold="true"
CurrentNodeStyle-ForeColor="red"
CurrentNodeStyle-Font-Underline="false">
<NODETEMPLATE>
<asp:CheckBox id="CheckBox1" runat="server" Checked="true" />
<asp:TextBox id="TextBox1" runat="server" Text="Declarative template" />
</NODETEMPLATE>
</asp:SiteMapPath>
</form>
</body>
</html>
Remarques
Définissez l’objet NodeTemplate sur lequel ITemplate utiliser un Image ou un autre contrôle, tel qu’un Labelélément d’interface utilisateur pour tous les nœuds de chemin de navigation.
Si la NodeTemplate propriété est définie, le modèle remplace le texte du nœud de navigation affiché et tout NodeStyle élément appliqué. Pour les nœuds actuels et racines, s’il s’agit d’un ou d’un CurrentNodeTemplate ensemble, ces modèles remplacent le NodeTemplate.RootNodeTemplate
Vous pouvez définir la NodeTemplate propriété de manière déclarative sur n’importe quel contrôle de serveur Web, et l’infrastructure ASP.NET effectue les étapes nécessaires pour encapsuler le contrôle de serveur Web en tant qu’objetITemplate. Toutefois, les contrôles de serveur web n’implémentent pas l’interface ITemplate ; par conséquent, lorsque vous utilisez les ITemplate propriétés par programmation, vous devez écrire un ITemplate wrapper pour tout code de modèle. Ensuite, la RootNodeTemplate propriété est définie sur une instance du ITemplate wrapper.