BulletedList.Target Proprietà

Definizione

Ottiene o imposta la finestra o il frame di destinazione in cui visualizzare il contenuto della pagina Web collegato quando viene fatto clic su un collegamento ipertestuale in un controllo BulletedList.

public:
 virtual property System::String ^ Target { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.TargetConverter))]
public virtual string Target { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.TargetConverter))>]
member this.Target : string with get, set
Public Overridable Property Target As String

Valore della proprietà

Finestra o frame di destinazione in cui caricare la pagina Web collegata quando si fa clic su un collegamento ipertestuale in un oggetto BulletedList. Il valore predefinito è una stringa vuota ("").

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come creare un BulletedList controllo e impostare la Target proprietà. Quando l'utente seleziona la HyperLink modalità di visualizzazione dalla casella di riepilogo, la Target proprietà è impostata su per _blank visualizzare la pagina collegata in una nuova finestra del browser.

<%@ 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>DisplayMode Example</title>
<script runat="server">
  
  void Index_Changed(object sender, System.EventArgs e)
  {

      // Change the message displayed, based on 
      // the display mode selected from the list box.
      if (DisplayModeListBox.SelectedIndex > -1)
      {
          Message1.Text = "You chose: " + DisplayModeListBox.SelectedItem.Text;
      }

      // Change the display mode, based on 
      // the mode selected from the list box.
      switch (DisplayModeListBox.SelectedIndex) 
    {
          case 0:
              ItemsBulletedList.DisplayMode = BulletedListDisplayMode.Text;
              Message2.Text = "";
              break;
          case 1:
              ItemsBulletedList.DisplayMode = BulletedListDisplayMode.HyperLink;
              // Opens a new browser window to display the page linked to.
              ItemsBulletedList.Target = "_blank";
              Message2.Text = "";
              break;
          case 2:
              ItemsBulletedList.DisplayMode = BulletedListDisplayMode.LinkButton;
              break;
          default:
              throw new Exception("You did not select a valid display mode.");
              break;
      }

  }

  void ItemsBulletedList_Click(object sender, System.Web.UI.WebControls.BulletedListEventArgs e)
  {

      // Change the message displayed, based on the index
      // of the bulletedlist list item that was clicked.
      switch (e.Index) 
    {
          case 0:
              Message2.Text = "You  clicked list item 1.";
              break;
          case 1:
              Message2.Text = "You  clicked list item 2.";
              break;
          case 2:
              Message2.Text = "You  clicked list item 3.";
              break;
          default:
              throw new Exception("You did not click a valid list item.");
              break;
      }

  }

</script>

</head>
<body>

  <h3>DisplayMode Example</h3>

  <form id="form1" runat="server">

    <h3>BulletedListDisplayMode Example</h3>

    <p>
    <asp:BulletedList id="ItemsBulletedList" 
      BulletStyle="Disc"
      DisplayMode="Text" 
      OnClick="ItemsBulletedList_Click"
      runat="server">    
      <asp:ListItem Value="http://www.cohowinery.com">Coho Winery</asp:ListItem>
      <asp:ListItem Value="http://www.contoso.com">Contoso, Ltd.</asp:ListItem>
      <asp:ListItem Value="http://www.tailspintoys.com">Tailspin Toys</asp:ListItem>
    </asp:BulletedList></p>

    <hr />

    <h4>Select from the list to change the display mode:</h4>
    <asp:ListBox id="DisplayModeListBox" 
      Rows="1"
      SelectionMode="Single"
      AutoPostBack="True"
      OnSelectedIndexChanged="Index_Changed"
      runat="server">
        <asp:ListItem>Text</asp:ListItem>
        <asp:ListItem>Hyperlink</asp:ListItem>
        <asp:ListItem>LinkButton</asp:ListItem>
    </asp:ListBox>

    <asp:Label id="Message1" 
      runat="server"
      AssociatedControlID="DisplayModeListBox"/><br /><br />

    <asp:Label id="Message2"
      runat="server"
      AssociatedControlID="DisplayModeListBox"/>

   </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>DisplayMode Example</title>
<script runat="server">

  Sub Index_Changed(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Change the message displayed, based on 
    ' the display mode selected from the list box.
    If DisplayModeListBox.SelectedIndex > -1 Then
      Message1.Text = "You chose: " & DisplayModeListBox.SelectedItem.Text
    End If

    ' Change the display mode, based on 
    ' the mode selected from the list box.
    Select Case (DisplayModeListBox.SelectedIndex)
      Case 0
        ItemsBulletedList.DisplayMode = BulletedListDisplayMode.Text
        Message2.Text = ""
      Case 1
        ItemsBulletedList.DisplayMode = BulletedListDisplayMode.HyperLink
        ' Opens a new browser window to display the page linked to.
        ItemsBulletedList.Target = "_blank"
        Message2.Text = ""
      Case 2
        ItemsBulletedList.DisplayMode = BulletedListDisplayMode.LinkButton
      Case Else
        Throw New Exception("You did not select a valid display mode.")
    End Select

  End Sub

  Sub ItemsBulletedList_Click(ByVal sender As Object, _
                              ByVal e As System.Web.UI.WebControls.BulletedListEventArgs)

    ' Change the message displayed, based on the index
    ' of the bulletedlist list item that was clicked.
    Select Case (e.Index)
      Case 0
        Message2.Text = "You  clicked list item 1."
      Case 1
        Message2.Text = "You  clicked list item 2."
      Case 2
        Message2.Text = "You  clicked list item 3."
      Case Else
        Throw New Exception("You did not click a valid list item.")
    End Select

  End Sub

</script>

</head>
<body>

  <h3>DisplayMode Example</h3>

  <form id="form1" runat="server">

    <h3>BulletedListDisplayMode Example</h3>

    <p>
    <asp:BulletedList id="ItemsBulletedList" 
      BulletStyle="Disc"
      DisplayMode="Text" 
      OnClick="ItemsBulletedList_Click"
      runat="server">    
      <asp:ListItem Value="http://www.cohowinery.com">Coho Winery</asp:ListItem>
      <asp:ListItem Value="http://www.contoso.com">Contoso, Ltd.</asp:ListItem>
      <asp:ListItem Value="http://www.tailspintoys.com">Tailspin Toys</asp:ListItem>
    </asp:BulletedList></p>

    <hr />

    <h4>Select from the list to change the display mode:</h4>
    <asp:ListBox id="DisplayModeListBox" 
      Rows="1"
      SelectionMode="Single"
      AutoPostBack="True"
      OnSelectedIndexChanged="Index_Changed"
      runat="server">
        <asp:ListItem>Text</asp:ListItem>
        <asp:ListItem>Hyperlink</asp:ListItem>
        <asp:ListItem>LinkButton</asp:ListItem>
    </asp:ListBox>

    <asp:Label id="Message1" 
      runat="server"
      AssociatedControlID="DisplayModeListBox"/><br /><br />

    <asp:Label id="Message2"
      runat="server"
      AssociatedControlID="DisplayModeListBox"/>

   </form>

</body>
</html>

Commenti

I valori devono iniziare con una lettera nell'intervallo di A tramite Z (senza distinzione tra maiuscole e minuscole), ad eccezione dei valori speciali elencati nella tabella seguente, che iniziano con un carattere di sottolineatura.

Valore Descrizione
_blank Visualizza il contenuto in una nuova finestra senza frame.
_parent Esegue il rendering del contenuto nell'elemento padre del set di frame immediato.
_search Visualizza il contenuto nel riquadro di ricerca.
_self Consente di visualizzare il contenuto nel frame attivo.
_top Visualizza il contenuto in tutta la finestra senza frame.

Nota

Controllare nella documentazione relativa al browser se è supportato il valore _search. Ad esempio, Microsoft Internet Explorer 5.0 e versioni successive supportano il valore di destinazione _search.

Utilizzare la Target proprietà per specificare la cornice o la finestra che visualizza la pagina Web collegata a quando viene fatto clic su un collegamento ipertestuale in un BulletedList controllo. Per visualizzare il contenuto degli elementi dell'elenco come collegamenti ipertestuali in un BulletedList controllo, impostare la proprietà sul BulletedListDisplayMode valore HyperLink. Impostare quindi la Value proprietà di ogni elemento dell'elenco sull'URL della pagina Web su cui passare.

Se la proprietà non è impostata, il browser o la Target finestra con lo stato attivo viene aggiornato quando viene fatto clic sul collegamento ipertestuale.

Nota

La Target proprietà viene eseguito come target attributo. L'attributo target sugli anchor elementi non è consentito nella definizione del tipo di documento XHTML 1.1. Non impostare la proprietà se l'output di cui è stato eseguito il Target rendering per l'oggetto BulletedList deve essere conforme a XHTML 1.1. Per altre informazioni, vedere l'argomento Standard XHTML in Visual Studio e ASP.NET.

Quando si creano pagine Web accessibili, è consigliabile evitare di usare la proprietà per eseguire la Target destinazione di un'altra finestra. Per altre informazioni, vedere Accessibilità in Visual Studio e ASP.NET.

Il valore di questa proprietà viene archiviato nello stato di visualizzazione.

Si applica a

Vedi anche