Partager via


HtmlTextArea.Value Propriété

Définition

Obtient ou définit le texte entré dans le HtmlTextArea contrôle.

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

Valeur de propriété

Texte entré dans le HtmlTextArea contrôle. La valeur par défaut est Empty.

Exemples

L’exemple de code suivant montre comment utiliser la Value propriété pour déterminer le contenu du HtmlTextArea contrôle. Le contenu est ensuite affiché dans la page Web.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void SubmitBtn_Click(Object sender, EventArgs e)
  {
    Span1.InnerHtml = "You wrote: <br />" + TextArea1.Value;
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTextArea Example</title>
</head>
<body>

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

      <h3>HtmlTextArea Example</h3>

      Enter your comments: <br />

      <textarea rows="2" cols="20" id="TextArea1" 
                runat="server"/>

      <br />

      <input type="submit"  
             value="Submit" 
             onserverclick="SubmitBtn_Click" 
             runat="server"/>

      <br />

      <span id="Span1" 
            runat="server" />

   </form>

</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As EventArgs)
      
    Span1.InnerHtml = "You wrote: <br />" + TextArea1.Value
      
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <title>HtmlTextArea Example</title>
</head>
<body>

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

      <h3>HtmlTextArea Example</h3>

      Enter your comments: <br />

      <textarea rows="2" cols="20" id="TextArea1" 
                runat="server"/>

      <br />

      <input type="submit"  
             value="Submit" 
             onserverclick="SubmitBtn_Click" 
             runat="server"/>

      <br />

      <span id="Span1" 
            runat="server" />

   </form>

</body>
</html>

Remarques

Utilisez la Value propriété pour contrôler par programmation le texte entré dans le HtmlTextArea contrôle. Cette propriété est couramment utilisée pour récupérer le texte entré dans la zone de texte, mais vous pouvez également l’utiliser pour spécifier le texte à afficher dans le contrôle. Cela est utile si vous souhaitez fournir une valeur par défaut ou afficher un message dans le HtmlTextArea contrôle.

Avertissement

Ce contrôle peut être utilisé pour afficher l’entrée utilisateur, qui peut inclure un script client malveillant. Vérifiez les informations envoyées à partir d’un client pour le script exécutable, les instructions SQL ou tout autre code avant de l’afficher dans votre application. ASP.NET fournit une fonctionnalité de validation de demande d’entrée pour bloquer le script et le code HTML dans l’entrée utilisateur. Les contrôles de serveur de validation sont également fournis pour évaluer l’entrée utilisateur. Pour plus d’informations, consultez La syntaxe de contrôle du serveur de validation.

S’applique à

Voir aussi