ARTICLE

Input Controls in ASP.Net

Posted by Abhimanyu Kumar Vatsa Articles | ASP.NET using VB.NET July 03, 2010
This article will explain about Input controls available in ASP.NET.
 
Reader Level:


Introduction and Demonstration

Input controls let the user enter text data into the application. ASP.NET supports only one input web control: the TextBox. The TextBox behaves like a single-line or multiline edit control, depending on the value of its TextMode property.

Its simplified syntax is as follows:


<
asp:textbox id="SingleText"
text
="Single Line TextBox"

runat="server" />

<
asp:textbox id="PasswordText"
text
="Password"
textmode
="Password"
runat
="server" />

<asp:textbox id="MultiText"
text
="Multiline TextBox"
textmode
="Multiline"
runat
="server" />


The TextBox control can then be accessed programmatically with a code fragment like:

SingleText.Text = "Hello ASP.NET"
PasswordText.Attributes("Value") = "New Password"
MultiText.Text = "Multiline TextBox can hold many lines of text"


Note that the text of a TextBox control using the Password text mode cannot be set directly using the Text property, but can be set using the attributes collection as shown in the preceding code snippet (though this is not recommended, since it results in the password being rendered to the client in plain text).

Index.aspx Page


<%@ Page Language="vb" %> 
<
html> 
<
head> 
   <title>Input Control Example</title> 
   <script runat="server"> 
      Sub Page_Load( ) 
         SingleText.Text = "Hello ASP.NET" 
         PasswordText.Attributes("Value") = "New Password" 
         MultiText.Text = "Multiline TextBox can hold many lines of text" 
      End Sub 
   </script> 

</
head> 
<
body> 
   <h1>Input Control Example</h1> 
   <form id="Form1" runat="server"> 
      <table border="1" cellpadding="5" cellspacing="0"> 
         <tr> 
            <td> 

               Single Line TextBox: 
            </td> 
            <td> 
               <asp:textbox id="SingleText"  
                  text="Single Line TextBox"  
                  runat="server" /> 
            </td> 
         </tr> 
         <tr> 
            <td> 

               Password TextBox: 
            </td> 
            <td> 
               <asp:textbox id="PasswordText"
                  text="Password"  
                  textmode="Password"  
                  runat="server" /> 
            </td> 
         </tr> 
         <tr> 
            <td> 

               Multiline TextBox: 

            </td> 
            <td>
                <asp:textbox id="MultiText"  
                  text="Multiline TextBox"  
                  textmode="Multiline"  
                  runat="server" /> 
            </td> 
         </tr> 
      </table> 
   </form>
 
</body> 
</html>


HAVE A HAPPY CODING!

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Nevron Diagram
Become a Sponsor