2010-08-15 31 views
27

ottengo questo come puro HTML:Come utilizzare l'etichetta in un webform ASP.Net?

<label for="txtPais">Pais:</label>  
<input name="ctl00$ContentPlaceHolder1$txtPais" type="text" id="ctl00_ContentPlaceHolder1_txtPais" class="textInput" /> 

Nel mio codice attuale in Visual Studio ho questo:

<label for="txtPais">Pais:</label>  
<asp:TextBox ID="txtPais" runat="server" CssClass="textInput"></asp:TextBox> 

Come dovrei applicare un'etichetta per questo campo testo?

+0

Possibile duplicato di http://stackoverflow.com/questions/493801/html-label-tag-and-asp-net – goodeye

risposta

54

è necessario utilizzare il <asp:Label...> come dettagliato in this blog post su Haacked

<asp:Label id="label" AssociatedControlId="txtPais" Text="Pais:" runat="server" /> 
<asp:TextBox id="txtPais" runat="server" CssClass="textInput" /> 

Questo dovrebbe convertire correttamente con l'ID in fase di conversione.

Problemi correlati