Search code examples
c#asp.netwebformscode-behind

How to access an "<input type="text" from code behind in ASP NET


This is my control

<div class="input-field col s6">
        <textarea id="txtDescrizione" name="txtDescrizione" class="materialize-textarea" runat="server" data-length="120" style:"display:none"></textarea>
        <label for="textarea1">Descrizione</label>
</div>

I just can't access it from code behind.

When I try

txtDescrizione.Visible = false;

It gives me error "txtDescrizione does not exists".


Solution

  • you can change textarea to asp:TextBox

    <asp:TextBox id="txtDescrizione" TextMode="multiline" Columns="50" Rows="5" runat="server" />