TreeView.Target Propriedade

Definição

Obtém ou define a janela ou o quadro de destino no qual deverá ser exibido o conteúdo da página da Web associado a um nó.Gets or sets the target window or frame in which to display the Web page content that is associated with a node.

public:
 property System::String ^ Target { System::String ^ get(); void set(System::String ^ value); };
public string Target { get; set; }
member this.Target : string with get, set
Public Property Target As String

Valor da propriedade

String

A janela de destino ou quadro no qual exibir o conteúdo da página da Web vinculada.The target window or frame in which to display the linked Web page content. Os valores devem começar com uma letra no intervalo de A a Z (não diferencia maiúsculas de minúsculas), exceto para determinados valores especiais que começam com um sublinhado, conforme mostrado na tabela a seguir.Values must begin with a letter in the range of A through Z (case insensitive), except for certain special values that begin with an underscore, as shown in the following table.

Valor de destinoTarget value Renderiza o conteúdo emRenders the content in
_blank Uma nova janela sem quadros.A new window without frames.
_parent O conjunto de quadros pai imediato.The immediate frameset parent.
_search O painel de pesquisa.The search pane.
_self O quadro com o foco.The frame with focus.
_top A janela inteira sem quadros.The full window without frames.

O padrão é uma cadeia de caracteres vazia (""), que atualiza a janela ou quadro com o foco.The default is an empty string (""), which refreshes the window or frame with focus.

Exemplos

O exemplo de código a seguir demonstra como usar a Target propriedade para exibir o conteúdo da Web que está vinculado a um nó em uma nova janela quando esse nó é clicado.The following code example demonstrates how to use the Target property to display the Web content that is linked to a node in a new window when that node is clicked.


<%@ Page Language="C#" %>

<!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>TreeView Target Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView Target Example</h3>
      
      <asp:TreeView id="LinksTreeView"
         Target="_blank" 
         runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page1">
               
              <asp:TreeNode Value="Section 1" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"/>
                 
            </asp:TreeNode>              
            
            <asp:TreeNode Value="Page 2" 
              NavigateUrl="Page2.aspx"
              Text="Page 2">
               
            </asp:TreeNode> 
            
          </asp:TreeNode>
        
        </Nodes>
        
      </asp:TreeView>

    </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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeView Target Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView Target Example</h3>
      
      <asp:TreeView id="LinksTreeView"
         Target="_blank" 
         runat="server">
         
        <Nodes>
        
          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Expanded="True">
             
            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page1">
               
              <asp:TreeNode Value="Section 1" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"/>
                 
            </asp:TreeNode>              
            
            <asp:TreeNode Value="Page 2" 
              NavigateUrl="Page2.aspx"
              Text="Page 2">
               
            </asp:TreeNode> 
            
          </asp:TreeNode>
        
        </Nodes>
        
      </asp:TreeView>

    </form>
  </body>
</html>

Comentários

Use a Target propriedade para especificar a janela ou o quadro no qual exibir o conteúdo da Web que está vinculado a um nó quando esse nó é clicado.Use the Target property to specify the window or frame in which to display the Web content that is linked to a node when that node is clicked.

Observação

A Target propriedade é renderizada como um target atributo.The Target property renders as a target attribute. O target atributo em anchor elementos não é permitido na definição de tipo de documento XHTML 1,1.The target attribute on anchor elements is not allowed in the XHTML 1.1 document type definition. Não defina a Target propriedade se a saída renderizada para o TreeView deve ser compatível com XHTML 1,1.Do not set the Target property, if the rendered output for the TreeView must be XHTML 1.1 compliant. Para obter mais informações, consulte padrões XHTML no Visual Studio e ASP.net.For more information, see XHTML Standards in Visual Studio and ASP.NET.

Ao criar páginas da Web acessíveis, você deve evitar usar a Target propriedade para direcionar outra janela.When creating accessible Web pages, you should avoid using the Target property to target another window. Para obter mais informações, consulte controles e acessibilidade do ASP.net.For more information, see ASP.NET Controls and Accessibility.

O valor dessa propriedade é armazenado em estado de exibição.The value of this property is stored in view state.

Aplica-se a

Confira também