Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Propriedade SiteMapNode.Url

 

Obtém ou define a URL da página que o objeto SiteMapNode representa.

Namespace:   System.Web
Assembly:  System.Web (em System.Web.dll)

public virtual string Url { get; set; }

Valor da Propriedade

Type: System.String

A URL da página que o nó representa. O padrão é String.Empty.

Exception Condition
InvalidOperationException

O nó é somente leitura.

The T:System.Web.XmlSiteMapProvider class, which is the default site map provider implementation for ASP.NET, uses the P:System.Web.SiteMapNode.Url property as a lookup key. Therefore, any T:System.Web.SiteMapNode object that is used by the T:System.Web.XmlSiteMapProvider class must have a unique URL within the scope of the provider.

Leading and trailing white-space characters are ignored.

The following code example demonstrates how to set the P:System.Web.SiteMapNode.Url property of a T:System.Web.SiteMapNode object. The AccessSiteMapProvider stores its root node as a row that has no parentnodeid defined. The row is returned using an T:System.Data.OleDb.OleDbDataReader object, and T:System.Web.SiteMapNode properties are set from the values in the data reader.

This code example is part of a larger example provided for the T:System.Web.SiteMapProvider class.

// Build an in-memory representation from persistent
// storage, and return the root node of the site map.
public override SiteMapNode BuildSiteMap() {

    // Since the SiteMap class is static, make sure that it is
    // not modified while the site map is built.
    lock(this) {

        // If there is no initialization, this method is being
        // called out of order.
        if (! IsInitialized) {
            throw new Exception("BuildSiteMap called incorrectly.");
        }

        // If there is no root node, then there is no site map.
        if (null == rootNode) {
            // Start with a clean slate
            Clear();

            // Select the root node of the site map from Microsoft Access.
            int rootNodeId = -1;

            if (accessConnection.State == ConnectionState.Closed)
                accessConnection.Open();
            OleDbCommand rootNodeCommand =
                new OleDbCommand("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid IS NULL",
                                 accessConnection);
            OleDbDataReader rootNodeReader = rootNodeCommand.ExecuteReader();

            if(rootNodeReader.HasRows) {
                rootNodeReader.Read();
                rootNodeId = rootNodeReader.GetInt32(0);
                // Create a SiteMapNode that references the current StaticSiteMapProvider.
                rootNode   = new SiteMapNode(this,
                                             rootNodeId.ToString(),
                                             rootNodeReader.GetString(1),
                                             rootNodeReader.GetString(2));

            }
            else return null;

            rootNodeReader.Close();
            // Select the child nodes of the root node.
            OleDbCommand childNodesCommand =
                new OleDbCommand("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid = ?",
                                 accessConnection);
            OleDbParameter rootParam = new OleDbParameter("parentid", OleDbType.Integer);
            rootParam.Value = rootNodeId;
            childNodesCommand.Parameters.Add(rootParam);

            OleDbDataReader childNodesReader = childNodesCommand.ExecuteReader();

            if (childNodesReader.HasRows) {

                SiteMapNode childNode = null;
                while(childNodesReader.Read()) {
                    childNode =  new SiteMapNode(this,
                                                 childNodesReader.GetInt32(0).ToString(),
                                                 childNodesReader.GetString(1),
                                                 childNodesReader.GetString(2));

                    // Use the SiteMapNode AddNode method to add
                    // the SiteMapNode to the ChildNodes collection.
                    AddNode(childNode, rootNode);
                }
            }

            childNodesReader.Close();
            accessConnection.Close();
        }
        return rootNode;
    }
}

.NET Framework
Disponível desde 2.0
Retornar ao início
Mostrar: