Dotnet 3.5 interview questions and answers Headline Animator

Wednesday, September 9, 2009

How to use textbox

HTML Helper for TextBox will be rendered as input elements in HTML. Check the below code.

  1. <!--HTML helper method for TextBox with ID only -->  
  2. <%= Html.TextBox("txtFirstName") %>  
  3. <input id="txtFirstName" name="txtFirstName" type="text" value="" />  
  4.   
  5. <!--HTML helper method for TextBox with ID and Value -->  
  6. <%= Html.TextBox("txtFirstName","Alice") %>  
  7. <input id="txtFirstName" name="txtFirstName" type="text" value="Alice" />  
  8.   
  9. <!--HTML helper method for TextBox with ID and Value and custom attributes. use '@' if the attribute name is keyword in C# or VB -->  
  10. <%= Html.TextBox("txtFirstName", "Alice", new { @class="error"client_selector="alphanumeric" })%>  
  11. <input class="error" client_selector="alphanumeric" id="txtFirstName" name="txtFirstName" type="text" value="Alice" /> 

No comments:

Post a Comment