ToolBox HTML Control HTMLText

HTML Text Web Server Control

In ASP.NET environment,This article describes you how to work with HTML Text Control.In HTML environment, Text is an object that represents a Textbox in an HTML form. The Textbox control in a HTML form contains all instance of an <input type="text"> tag. Likewise, There are one more kind of textbox is <input type="password"> and <input type="reset">

There are several functions available to access the HTML Text.some of its funtions are as follows,

  • document.getElementById()
  • document.getElementByName()
Text Objects Properties
  • id -Sets or returns the id of a Text
  • form -Returns a reference to the form that contains the Text
  • accessKey -Sets or returns the keyboard key to access a Text
  • alt -Sets or returns an alternate text to display if a browser does not support Texts
  • disabled -Sets or returns whether or not a Text should be disabled
  • tabIndex -Sets or returns the tab order for a Text
  • name -Sets or returns the name of a Text
  • type -Returns the type of form element a Text is
  • maxLength - Sets or returns the maximum number of characters in a text field
  • readOnly -Sets or returns whether or not a text field should be read-only
  • value -Sets or returns the text that is displayed on the Text
  • title -Sets or returns an element's advisory title
  • lang -Sets or returns the language code for an element
  • dir -Sets or returns the direction of text
  • className -Sets or returns the class attribute of an element
Text Objects Methods
  • blur() -Performs focus when leave from the control
  • click() -Simulates a mouse-click on a Text
  • focus() -Performs focus when enter into the control

The following code snippets explains you the HTML Text in the web form.

in .aspx.cs page,

protected void AddButton_Click(Object sender, EventArgs e)
      {
         int Answer;
         Answer = Convert.ToInt32(txt1.Value) + Convert.ToInt32(txt2.Value);
         AnswerMessage.InnerHtml = Answer.ToString();
      }
        

in .aspx page,

 <form id="Form2" runat="server">
      <h3>Example </h3>
      <table>         
         <tr align="center">
            <td>
               <input ID="txt1"
                     Type="Text"
                      Size="2"
                      MaxLength="3"
                      Value="1"
                     runat="server"/>
            </td>
            <td>
               + 
            </td>
            <td>
               <input ID="txt2"
                     Type="Text"
                      Size="2"
                      MaxLength="3"
                      Value="1"
                      runat="server"/>
            </td>
            <td>
               =
            </td>
            <td>
              <span ID="AnswerMessage"
                     runat="server"/>
            </td>
         </tr>
         <tr>
            <td colspan="2">
               <asp:RequiredFieldValidator
                    ID="req1"
                    ControlToValidate="txt1"
                    ErrorMessage="Please enter a value.<br>"
                    Display="Dynamic"
                    runat="server"/>

               <asp:CompareValidator
                    ID="comp1"
                    ControlToValidate="txt1"
                    Operator="LessThan"
                    Type="Integer"
                    ValueToCompare="100"
                    ErrorMessage="Please enter an integer less than 100.<br>"
                    Display="Dynamic"
                    runat="server"/>
               <asp:CompareValidator
                    ID="comp2"
                    ControlToValidate="txt1"
                    Operator="GreaterThan"
                    Type="Integer"
                    ValueToCompare="0"
                    ErrorMessage="Please enter an integer greater than 0.<br>"
                    Display="Dynamic"
                   runat="server"/>
            </td>
            <td colspan="2">
               <asp:RequiredFieldValidator
                    ID="req2"
                    ControlToValidate="txt2"
                    ErrorMessage="Please enter a value.<br>"
                    Display="Dynamic"
                    runat="server"/>

               <asp:CompareValidator
                    ID="comp3"
                    ControlToValidate="txt2"
                    Operator="LessThan"
                    Type="Integer"
                    ValueToCompare="100"
                    ErrorMessage="Please enter an integer less than 100.<br>"
                    Display="Dynamic"
                    runat="server"/>

               <asp:CompareValidator
                    ID="comp4"
                    ControlToValidate="txt2"
                    Operator="GreaterThan"
                    Type="Integer"
                    ValueToCompare="0"
                    ErrorMessage="Please enter an integer greater than 0.<br>"
                    Display="Dynamic"
                    runat="server"/>
            </td>
            <td>
                 
            </td>
         </tr>
         <tr align="center">
            <td colspan="4">
               <input id="Submit1" Type="Submit"
                      Name="AddButton"
                      Value="Add"
                      OnServerClick="AddButton_Click"
                      runat="server"/>
                  
               <input id="Reset1" Type="Reset"
                      Name="AddButton"
                      Value="Reset"
                      runat="server"/>
            </td>
            <td>
                
            </td>
         </tr>
      </table>
   </form>
        
 
Related Links

Posted by: Admin
Posted on: 9/18/2009 at 4:55 PM
Tags: , ,
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (21) | Post RSSRSS comment feed

Comments

Onlineatoz.net

Friday, September 18, 2009 4:56 PM

trackback

ToolBox HTML Control HTMLTextArea

ToolBox HTML Control HTMLTextArea

computers keyboard United States

Thursday, April 22, 2010 4:26 PM

computers keyboard

Definitely a great post. Hats off to you! The information that you have provided is very helpful.

led tube People's Republic of China

Friday, May 28, 2010 5:42 AM

led tube

I am really enjoying reading your well written articles. I think you spend numerous effort and time updating your blog. I have bookmarked it and I am taking a look ahead to reading new articles. Please keep up the good articles!

casual clothing People's Republic of China

Wednesday, June 02, 2010 9:11 AM

casual clothing

Although I can't agree with all you staded, I must confess I do love your way of writing.

cheap ghds People's Republic of China

Wednesday, June 02, 2010 9:12 AM

cheap ghds

Great article! Information is Always KEY. BTW I love how simple your blog layout is!

ugg boots People's Republic of China

Saturday, June 26, 2010 4:03 AM

ugg boots

Well , the view of the passage is totally correct ,your details is really  reasonable and  you <a href=" http://www.discountbootsonsale.co.uk/
" >wslmart.net </a> guy give us  valuable  informative post, I totally agree the standpoint of upstairs. I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!

down jackets People's Republic of China

Monday, June 28, 2010 11:08 AM

down jackets

Well , the view of the passage is totally correct ,your details is really  reasonable and  you <a href=" http://in-the-information.com/ " >wslmart.net </a> guy give us  valuable  informative post, I totally agree the standpoint of upstairs. I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!

wholesale replica rolex watches People's Republic of China

Tuesday, June 29, 2010 8:46 AM

wholesale replica rolex watches

I am SO attracted to palm trees!

Thanks for the interesting facts too!

fuel saver People's Republic of China

Tuesday, June 29, 2010 8:47 AM

fuel saver

Hi! For everybody please ! This site is a good site. Do not misuse it's content. We are happy to have it nice. please!

nfl jersey People's Republic of China

Thursday, July 01, 2010 2:50 AM

nfl jersey

Thanks for the info!!

wholesale edhardy United States

Thursday, July 01, 2010 11:30 AM

wholesale edhardy

Thanks for doing this blog, really interesting stuff.

moncler down jackets People's Republic of China

Friday, July 02, 2010 7:09 AM

moncler down jackets

He also backs tightening border security and clamping down on employers that <a href=" www.moncler-jackets-outlet.com/.../ " >wslmart.net </a> hire undocumented workers. He highlighted those points on Thursday, while saying the slow system of processing legal immigrants must be fixed, too.

white light teeth United States

Sunday, July 04, 2010 2:01 AM

white light teeth

one  The account claimed that a important discovery had been produced by a lady in  should you can think it  my hometown  I live in Kelowna  BC  Canada  Its a modest town inside a smaller country  Thats why nobody reading this will have heard of it  What are the odds she and I could possibly be neighboursIJ Concerning the similar as those people on the great the teeth brightening costing five dollars

prada outlet People's Republic of China

Monday, July 05, 2010 7:50 AM

prada outlet

He also backs tightening border security and clamping down on employers that <a href="http://www.prada-outlet-store.com" >cheap prada</a> hire undocumented workers.
He highlighted those points on Thursday, while saying the slow system of processing legal immigrants must be fixed, too.

puma golf shoe People's Republic of China

Monday, July 19, 2010 9:15 AM

puma golf shoe

I have been looking around #hostname and really am impressed by the great content material here. I work the nightshift at my job and it really gets boring. I've been coming here for the previous couple nights and reading. I simply needed to let you know that I've been enjoying what I have seen and I look forward to reading more.
www.sfyh.com/NEC-programmer_2581_15187_prod.html

women's pajamas People's Republic of China

Tuesday, July 20, 2010 11:31 AM

women's pajamas

Hey, guy, your blog is nice. It can bring me many useful information.

speed breaker People's Republic of China

Tuesday, July 20, 2010 11:31 AM

speed breaker

I found a lot of great points in this post, nice

Ed hardy clothing United States

Tuesday, July 20, 2010 12:26 PM

Ed hardy clothing

Hello Guru, what entice you to post an article. This article was extremely interesting, especially since I was searching for thoughts on this subject last Thursday.

brown puma trainers United States

Wednesday, July 21, 2010 9:30 AM

brown puma trainers

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.

Timberland Boots sale United States

Thursday, July 29, 2010 11:43 AM

Timberland Boots sale

Through reading more good articles to improve our quality of life. Your blog make me feel comfortable. At the sametime,http://www.timberlandshoesonline.com I will introduce you to know about a comfortable shoes that makes your life better! you can choice what you like!

designer handbags Oman

Friday, July 30, 2010 7:48 AM

designer handbags


replica chanel http://www.topchanelbag.com
replica gucci http://www.topguccibags.com
replica hermes http://www.greathermes.com
replica louis vuitton http://www.greatlouisvuitton.com
discount handbags http://www.topdesignerhandbag.com
designer handbags http://www.wendysreplica.la

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading