{"id":3970,"date":"2022-12-17T04:16:34","date_gmt":"2022-12-17T04:16:34","guid":{"rendered":"https:\/\/isophal.com\/?p=3970"},"modified":"2022-12-17T04:17:00","modified_gmt":"2022-12-17T04:17:00","slug":"textbox-control-asp-net-server-control","status":"publish","type":"post","link":"https:\/\/isophal.com\/news\/2022\/12\/17\/3970.html\/","title":{"rendered":"TextBox Control \u2013 ASP.Net Server Control"},"content":{"rendered":"\n<p>Textbox control is most usable web server control in asp.net.<\/p>\n\n\n\n<p>TextBox control is a rectangular box which is used to take user to input. In simple word the TextBox is a place where user can input some text on asp.net web form. To use TextBox on page we can write code or just drag and drop from toolbox.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax of ASP.Net TextBox<\/h2>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p>&lt;asp:TextBox ID=\u201dTextBox1\u2033 runat=\u201dserver\u201d&gt;&lt;\/asp:TextBox&gt;<\/p><cite>All server side control has its own properties and events. below list shows textbox properties.<\/cite><\/blockquote><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Properties<\/th><th>Description<\/th><\/tr><tr><td>ID<\/td><td>Identification name of textbox control.<\/td><\/tr><tr><td>Text<\/td><td>It is used to display text in a control.<\/td><\/tr><tr><td>BackColor<\/td><td>It is used to set background color of textbox control.<\/td><\/tr><tr><td>ForColor<\/td><td>It is used to set text color of the control.<\/td><\/tr><tr><td>ToolTip<\/td><td>It displays a text on control when mouse over on it.<\/td><\/tr><tr><td>TabIndex<\/td><td>It is used&nbsp;manage tab order of control.<\/td><\/tr><tr><td>CssClass<\/td><td>It is used to apply style on control.<\/td><\/tr><tr><td>Enable<\/td><td>true\/false \u2013 used to enable or disable control.<\/td><\/tr><tr><td>Enable Theming<\/td><td>true\/false \u2013 It is used to enable or disable effect of theme on control.<\/td><\/tr><tr><td>CausesValidation<\/td><td>true\/false \u2013 It is used to enable or disable validation effect on control<\/td><\/tr><tr><td>Visible<\/td><td>true\/false \u2013 It is used to hide or visible control on web page.<\/td><\/tr><tr><td><\/td><td><strong>Important Properties of TextBox control<\/strong><\/td><\/tr><tr><td>MaxLenght<\/td><td>It is used to set maximum number of characters that can be input in TextBox.<\/td><\/tr><tr><td>TextMode<\/td><td>Single \/ Multiline \/ Password<\/td><\/tr><tr><td>ReadOnly<\/td><td>true\/false \u2013 used to enable or disable control readonly.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">TextBox Example in ASP.Net<\/h2>\n\n\n\n<p>Above list shows the properties of TextBox control. now, lets understand more about control using example in C#.net.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"538\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-21-1024x538.png\" alt=\"\" class=\"wp-image-3971\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-21-1024x538.png 1024w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-21-600x315.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-21-300x158.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-21.png 1200w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-21-768x403.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-21-1170x614.png 1170w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-21-585x307.png 585w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">TextBox control example in ASP.Net<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"925\" height=\"584\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-22.png\" alt=\"\" class=\"wp-image-3972\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-22.png 925w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-22-600x379.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-22-300x189.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-22-768x485.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-22-585x369.png 585w\" sizes=\"auto, (max-width: 925px) 100vw, 925px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Assign value to and retrieve value from a TextBox control<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>TextBox1.Text = \"ASP.Net with C#\";\nLabel1.Text = TextBox1.Text;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">TextBox Example<\/h3>\n\n\n\n<p>Assign a text to TextBox control when Button click event fires using c# in visual studio.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"251\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-23.png\" alt=\"\" class=\"wp-image-3973\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-23.png 493w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-23-300x153.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><figcaption class=\"wp-element-caption\">TextBox Control \u2013 ASP.Net Server Side Control.<\/figcaption><\/figure>\n\n\n\n<p>C# code for above TextBox example.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void btndisplay_Click(object sender, EventArgs e) { <br>TextBox1.Text = \"MEERA\"; <br>} <br>protected void btnclear_Click(object sender, EventArgs e) { <br>TextBox1.Text = \"\"; <br>}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"703\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-24-1024x703.png\" alt=\"\" class=\"wp-image-3974\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-24-1024x703.png 1024w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-24-600x412.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-24-300x206.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-24-768x527.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-24-1170x803.png 1170w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-24-585x402.png 585w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-24.png 1216w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"712\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-25-1024x712.png\" alt=\"\" class=\"wp-image-3975\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-25-1024x712.png 1024w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-25-600x417.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-25-300x209.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-25-768x534.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-25-1170x814.png 1170w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-25-585x407.png 585w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-25.png 1218w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>C# Code for above asp.net example<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\"><\/div><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void Button1_Click(object sender, EventArgs e)\n        {\n            TextBox1.TextMode = TextBoxMode.SingleLine;\n        }\n\n        protected void Button2_Click(object sender, EventArgs e)\n        {\n            TextBox1.TextMode = TextBoxMode.Password;\n        }\n\n        protected void Button3_Click(object sender, EventArgs e)\n        {\n            TextBox1.TextMode = TextBoxMode.MultiLine;\n        }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">TextBox Control Example<\/h2>\n\n\n\n<p>In this example we will change some textbox properties programmatically using c# in visual studio.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6-1024x555.png\" alt=\"\" class=\"wp-image-3977\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6-1024x555.png 1024w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6-600x325.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6-300x163.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6-768x416.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6-1536x832.png 1536w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6-1170x634.png 1170w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6-585x317.png 585w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/MicrosoftTeams-image-6.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">TextBox Control Example in ASP.Net<\/figcaption><\/figure>\n\n\n\n<p>C# Code for above asp.net example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void btnbackcolor_Click(object sender, EventArgs e) { \nTextBox1.BackColor = System.Drawing.Color.Yellow; \n}\n\nprotected void btnborder_Click(object sender, EventArgs e) { \nTextBox1.BorderStyle = BorderStyle.Solid; \nTextBox1.BorderColor = System.Drawing.Color.Red; \nTextBox1.BorderWidth = 3; \n}\n\nprotected void btnfontcolor_Click(object sender, EventArgs e) { \nTextBox1.ForeColor = System.Drawing.Color.Green; \n}\n\nprotected void btnfontbold_Click(object sender, EventArgs e) { \nTextBox1.Font.Bold = true; \n}\n\nprotected void btn10_Click(object sender, EventArgs e) {\nTextBox1.MaxLength = 10; \n} \n\nprotected void btnpassword_Click(object sender, EventArgs e) { \nTextBox1.TextMode = TextBoxMode.Password; \n} \n\nprotected void btnsingleline_Click(object sender, EventArgs e) {\nTextBox1.TextMode = TextBoxMode.SingleLine; \n} \n\nprotected void btnwidth_Click(object sender, EventArgs e) { \nTextBox1.Width = 200; \n} \n\nprotected void btncolor_Click(object sender, EventArgs e) { \nTextBox1.TextMode = TextBoxMode.Color; \n} \n\nprotected void btnnormal_Click(object sender, EventArgs e) { \nTextBox1.Text = \"\"; \nTextBox1.TextMode = TextBoxMode.SingleLine; \nTextBox1.MaxLength = 0; \nTextBox1.Font.Bold = false; \nTextBox1.BackColor = System.Drawing.Color.White; \nTextBox1.ForeColor = System.Drawing.Color.Black; \nTextBox1.BorderStyle = BorderStyle.Solid; \nTextBox1.BorderColor = System.Drawing.Color.Green; \nTextBox1.BorderWidth = 1; \nTextBox1.Width = 128; \n}<\/code><\/pre>\n\n\n\n<p>We hope that this asp.net tutorial helped you to understand about TextBox control.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Textbox control is most usable web server&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3971,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[189,140],"tags":[191],"class_list":["post-3970","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net","category-programming","tag-asp-net"],"_links":{"self":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/3970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/comments?post=3970"}],"version-history":[{"count":2,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/3970\/revisions"}],"predecessor-version":[{"id":3979,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/3970\/revisions\/3979"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/media\/3971"}],"wp:attachment":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/media?parent=3970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/categories?post=3970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/tags?post=3970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}