HyperLinkField.NavigateUrl HyperLinkField.NavigateUrl HyperLinkField.NavigateUrl HyperLinkField.NavigateUrl Property

Definizione

Ottiene o imposta l'URL a cui passare quando viene fatto clic su un collegamento ipertestuale in un oggetto HyperLinkField.Gets or sets the URL to navigate to when a hyperlink in a HyperLinkField object is clicked.

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

Valore della proprietà

URL a cui passare quando viene fatto clic su un collegamento ipertestuale in un oggetto HyperLinkField.The URL to navigate to when a hyperlink in a HyperLinkField is clicked. Il valore predefinito è una stringa vuota (""), a indicare che questa proprietà non è impostata.The default is an empty string (""), which indicates that this property is not set.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato NavigateUrl come utilizzare la proprietà per specificare una pagina Web statica a cui spostarsi quando si HyperLinkField fa clic su un collegamento ipertestuale in un oggetto.The following code example demonstrates how to use the NavigateUrl property to specify a static Web page to navigate to when a hyperlink in a HyperLinkField object 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>HyperLinkField Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>HyperLinkField Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- Set the HyperLinkField field column to a static     -->
      <!-- caption and URL.                                    -->
      <asp:gridview id="OrdersGridView" 
        datasourceid="OrdersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="OrderID" 
            headertext="OrderID"/>
          <asp:boundfield datafield="CustomerID" 
            headertext="Customer ID"/>
          <asp:boundfield datafield="OrderDate" 
            headertext="Order Date"
            dataformatstring="{0:d}" />
          <asp:hyperlinkfield text="Details..."
            navigateurl="~\details.aspx"            
            headertext="Order Details"
            target="_blank" />
                
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrdersSqlDataSource"  
        selectcommand="SELECT [OrderID], [CustomerID], [OrderDate] FROM [Orders]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </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>HyperLinkField Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>HyperLinkField Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- Set the HyperLinkField field column to a static     -->
      <!-- caption and URL.                                    -->
      <asp:gridview id="OrdersGridView" 
        datasourceid="OrdersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="OrderID" 
            headertext="OrderID"/>
          <asp:boundfield datafield="CustomerID" 
            headertext="Customer ID"/>
          <asp:boundfield datafield="OrderDate" 
            headertext="Order Date"
            dataformatstring="{0:d}" />
          <asp:hyperlinkfield text="Details..."
            navigateurl="~\details.aspx"            
            headertext="Order Details"
            target="_blank" />
                
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrdersSqlDataSource"  
        selectcommand="SELECT [OrderID], [CustomerID], [OrderDate] FROM [Orders]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

Commenti

Utilizzare la NavigateUrl proprietà per specificare l'URL a cui passare quando si fa clic su HyperLinkField un collegamento ipertestuale in un oggetto.Use the NavigateUrl property to specify the URL to navigate to when a hyperlink in a HyperLinkField object is clicked. Quando questa proprietà è impostata, ogni collegamento ipertestuale condivide lo stesso URL di navigazione.When this property is set, each hyperlink shares the same navigation URL.

Anziché utilizzare questa proprietà per impostare l'URL per i collegamenti ipertestuali, è possibile utilizzare la DataNavigateUrlFields proprietà per associare gli URL dei collegamenti ipertestuali a un campo in un'origine dati.Instead of using this property to set the URL for the hyperlinks, you can use the DataNavigateUrlFields property to bind the URLs of the hyperlinks to a field in a data source. In questo modo è possibile avere un URL diverso per ogni collegamento ipertestuale.This allows you to have a different URL for each hyperlink.

Nota

Se le DataNavigateUrlFields proprietà NavigateUrl e sono entrambe impostate, la DataNavigateUrlFields proprietà avrà la precedenza.If the DataNavigateUrlFields and NavigateUrl properties are both set, the DataNavigateUrlFields property takes precedence.

Si applica a

Vedi anche