HtmlTextArea.Name Property
Gets or sets the unique identifier name for the HtmlTextArea control.
[Visual Basic] Public Overridable Property Name As String [C#] public virtual string Name {get; set;} [C++] public: __property virtual String* get_Name(); public: __property virtual void set_Name(String*); [JScript] public function get Name() : String; public function set Name(String);
Property Value
A string that represents the value of the Control.UniqueID property.
Remarks
Use the Name property to determine the unique identifier name for the HtmlTextArea control. In this implementation of the property, the get accessor returns the value of the Control.UniqueID property. However, the set accessor does not assign a value to this property.
Note The set accessor does not assign a value to this property because the Name property must have the same value as the Control.UniqueID property for the HtmlTextArea control to work properly.
Classes that inherit from the HtmlTextArea class may override this implementation, if necessary.
Example
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <%@ Import Namespace="System.Data" %> <html> <script runat="server" > Sub Page_Load(sender As Object, e As EventArgs) ' Bind a data source to the Repeater control. Repeater1.DataSource = CreateRepeaterSource() Repeater1.DataBind() End Sub Sub Item_Bound(sender As Object, e As RepeaterItemEventArgs) ' The ItemDataBound event is raised when data is bound to an ' item in the Repeater control. Items can include the Header, ' Footer, and so on. Use the following logic only if the item ' being bound is an Item or AlternatingItem. If (e.Item.ItemType = ListItemType.Item) Or _ (e.Item.ItemType = ListItemType.AlternatingItem) Then ' The runtime automatically generates a unique identifier ' for each control embedded in a list control, such as the ' Repeater. The Name property of the HtmlSelect control ' contains this unique identifier and is commonly used to ' identify a specific control. ' Retrieve the HtmlTextArea control from the RepeaterItem. Dim area As HtmlTextArea = _ CType(e.Item.FindControl("TextArea1"), HtmlTextArea) ' Insert a custom message if the Name property contains the value ' "Repeater1:_ctl3:TextArea1". If area.Name = "Repeater1:_ctl3:TextArea1" Then area.Value = "Hello World" End If End If End Sub Function CreateRepeaterSource() As DataView ' Create a DataTable that contains sample data for the ' Repeater control. Dim dt As DataTable = New DataTable() Dim dr As DataRow dt.Columns.Add(new DataColumn("Category", GetType(String))) ' Populate the DataTable with sample values. Dim i As Integer For i = 0 To 4 dr = dt.NewRow() dr(0) = "Category " & i.ToString() dt.Rows.Add(dr) Next i ' Create a DataView from the DataTable. Dim dv As DataView = New DataView(dt) Return dv End Function </script> <body> <form runat="server"> <h3> HtmlTextArea Name Example </h3> Notice that Category 3 has custom text. <br> <asp:Repeater id="Repeater1" OnItemDataBound="Item_Bound" runat="server"> <ItemTemplate> <h4><%# DataBinder.Eval(Container.DataItem, "Category") %></h4> Enter text: <br> <textarea id="TextArea1" runat="server"/> <br><br> <hr> </ItemTemplate> </asp:Repeater> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <%@ Import Namespace="System.Data" %> <html> <script runat="server" > void Page_Load(Object sender, EventArgs e) { // Bind a data source to the Repeater control. Repeater1.DataSource = CreateRepeaterSource(); Repeater1.DataBind(); } void Item_Bound(Object sender, RepeaterItemEventArgs e) { // The ItemDataBound event is raised when data is bound to an // item in the Repeater control. Items can include the Header, // Footer, and so on. Use the following logic only if the item // being bound is an Item or AlternatingItem. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // The runtime automatically generates a unique identifier // for each control embedded in a list control, such as the // Repeater. The Name property of the HtmlSelect control // contains this unique identifier and is commonly used to // identify a specific control. // Retrieve the HtmlTextArea control from the RepeaterItem. HtmlTextArea area = (HtmlTextArea)e.Item.FindControl("TextArea1"); // Insert a custom message if the Name property contains the value // "Repeater1:_ctl3:TextArea1". if(area.Name == "Repeater1:_ctl3:TextArea1") { area.Value = "Hello World"; } } } DataView CreateRepeaterSource() { // Create a DataTable that contains sample data for the // Repeater control. DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new DataColumn("Category", typeof(String))); // Populate the DataTable with sample values. for (int i = 0; i < 5; i++) { dr = dt.NewRow(); dr[0] = "Category " + i.ToString(); dt.Rows.Add(dr); } // Create a DataView from the DataTable. DataView dv = new DataView(dt); return dv; } </script> <body> <form runat="server"> <h3> HtmlTextArea Name Example </h3> Notice that Category 3 has custom text. <br> <asp:Repeater id="Repeater1" OnItemDataBound="Item_Bound" runat="server"> <ItemTemplate> <h4><%# DataBinder.Eval(Container.DataItem, "Category") %></h4> Enter text: <br> <textarea id="TextArea1" runat="server"/> <br><br> <hr> </ItemTemplate> </asp:Repeater> </form> </body> </html>
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlTextArea Class | HtmlTextArea Members | System.Web.UI.HtmlControls Namespace | Control.UniqueID