Share via


HtmlTextArea.Value Propriété

Définition

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

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 contrôle HtmlTextArea. 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.

Attention

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 les 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. Des contrôles serveur de validation sont également fournis pour évaluer les entrées utilisateur. Pour plus d’informations, consultez Syntaxe du contrôle du serveur de validation.

S’applique à

Voir aussi