ImageField.ReadOnly Propriété

Définition

Obtient ou définit une valeur qui indique si les valeurs du champ spécifié par la propriété DataImageUrlField peuvent être modifiées en mode Édition.

public:
 virtual property bool ReadOnly { bool get(); void set(bool value); };
public virtual bool ReadOnly { get; set; }
member this.ReadOnly : bool with get, set
Public Overridable Property ReadOnly As Boolean

Valeur de propriété

Boolean

true pour indiquer que les valeurs de champ ne peuvent pas être modifiées en mode Édition ; sinon, false. La valeur par défaut est false.

Exemples

L’exemple suivant montre comment utiliser la ReadOnly propriété pour indiquer que les valeurs de champ qui représentent les URL des images affichées dans un ImageField objet ne peuvent pas être modifiées en mode édition.


<%@ 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>ImageField ReadOnly Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>ImageField ReadOnly Example</h3>
                       
      <asp:gridview id="EmployeesGrid"
        autogeneratecolumns="false"
        datasourceid="EmployeeSource"
        autogenerateeditbutton="true"
        datakeynames="EmployeeID"   
        runat="server">
      
        <columns>

          <asp:imagefield dataimageurlfield="PhotoPath"
            alternatetext="Employee Photo"
            nulldisplaytext="No image on file."
            headertext="Photo"  
            readonly="true"/>
          <asp:boundfield datafield="FirstName"
            headertext="First Name"/>
          <asp:boundfield datafield="LastName"
            headertext="Last Name"/>
        
        </columns>
        
      </asp:gridview>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [PhotoPath] From [Employees]"
        updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName Where [EmployeeId]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </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>ImageField ReadOnly Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>ImageField ReadOnly Example</h3>
                       
      <asp:gridview id="EmployeesGrid"
        autogeneratecolumns="false"
        datasourceid="EmployeeSource"
        autogenerateeditbutton="true"
        datakeynames="EmployeeID"   
        runat="server">
      
        <columns>

          <asp:imagefield dataimageurlfield="PhotoPath"
            alternatetext="Employee Photo"
            nulldisplaytext="No image on file."
            headertext="Photo"  
            readonly="true"/>
          <asp:boundfield datafield="FirstName"
            headertext="First Name"/>
          <asp:boundfield datafield="LastName"
            headertext="Last Name"/>
        
        </columns>
        
      </asp:gridview>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [PhotoPath] From [Employees]"
        updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName Where [EmployeeId]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

Remarques

Par défaut, les valeurs du champ spécifié par la DataImageUrlField propriété peuvent être modifiées par l’utilisateur lorsqu’un contrôle lié aux données est en mode édition. Pour empêcher l’utilisateur de modifier les valeurs du champ, définissez cette propriété truesur .

Notes

Dans un ImageField objet, la DataImageUrlField propriété contient généralement le nom du champ qui contient les URL des images affichées dans l’objet.

S’applique à

Voir aussi