{"id":3943,"date":"2022-12-17T02:03:51","date_gmt":"2022-12-17T02:03:51","guid":{"rendered":"https:\/\/isophal.com\/?p=3943"},"modified":"2022-12-17T03:13:29","modified_gmt":"2022-12-17T03:13:29","slug":"how-to-change-textbox-border-width-style-color-in-asp-net","status":"publish","type":"post","link":"https:\/\/isophal.com\/news\/2022\/12\/17\/3943.html\/","title":{"rendered":"How to change TextBox Border Width, Style, Color in ASP.NET"},"content":{"rendered":"\n<p>\u2013 Hi, In this ASP.NET Example we will learn how to&nbsp; change TextBox Control Border Style, Border width and border color in programmatically in ASP.NET.<\/p>\n\n\n\n<p>\u2013 First the Design the webfor with one TextBox along with the 3 button control in ASP.NET.<\/p>\n\n\n\n<p>For Design, write the below code in Body tag:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;form id=\"form1\" runat=\"server\"&gt;\n        &lt;center&gt;\n            &lt;table width=\"650\" class=\"auto-style1\"&gt;\n            &lt;tr&gt;\n            &lt;td colspan=\"3\" style=\"text-align: center;background-color:#FF6600;color:white;padding:15px;\"&gt;\n                &lt;h3&gt;How to change TextBox Border Width, Style, Color in ASP.NET&lt;\/h3&gt;&lt;\/td&gt;\n            &lt;\/tr&gt;\n            &lt;tr&gt;\n            &lt;td style=\"width: 100px; text-align: right\"&gt;\n                &amp;nbsp;&lt;\/td&gt;\n            &lt;td style=\"width: 100px\"&gt;\n                &amp;nbsp;&lt;\/td&gt;\n            &lt;td style=\"width: 100px\"&gt;\n                &amp;nbsp;&lt;\/td&gt;\n            &lt;\/tr&gt;\n            &lt;tr&gt;\n            &lt;td style=\"width: 100px; text-align: right\"&gt;\n            Enter Value :&lt;\/td&gt;\n            &lt;td style=\"width: 100px; text-align:center;\"&gt;\n            &lt;asp:TextBox ID=\"TextBox1\" runat=\"server\" CssClass=\"txt\" Height=\"21px\" Width=\"200px\"&gt;&lt;\/asp:TextBox&gt;&lt;\/td&gt;\n            &lt;td style=\"width: 100px\"&gt;\n            &lt;\/td&gt;\n            &lt;\/tr&gt;\n            &lt;tr&gt;\n            &lt;td style=\"width: 100px; text-align: right\"&gt;\n                &amp;nbsp;&lt;\/td&gt;\n            &lt;td style=\"width: 100px\"&gt;\n                &amp;nbsp;&lt;\/td&gt;\n            &lt;td style=\"width: 100px\"&gt;\n                &amp;nbsp;&lt;\/td&gt;\n            &lt;\/tr&gt;\n            &lt;tr&gt;\n            &lt;td colspan=\"3\" style=\"text-align: center\"&gt;\n            &amp;nbsp;&lt;asp:Button ID=\"Button1\" runat=\"server\" OnClick=\"Button1_Click\" Text=\"Border width\" BackColor=\"#FF6600\" ForeColor=\"#FFFF66\" \/&gt;\n            &amp;nbsp;&lt;asp:Button ID=\"Button2\" runat=\"server\" OnClick=\"Button2_Click\" Text=\"Border Style\" BackColor=\"#FF6600\" ForeColor=\"#FFFFCC\" \/&gt;\n            &amp;nbsp;&lt;asp:Button ID=\"Button3\" runat=\"server\" OnClick=\"Button3_Click\" Text=\"Border color\" BackColor=\"#FF6600\" ForeColor=\"White\" \/&gt;\n            &amp;nbsp;&lt;asp:Button ID=\"Button4\" runat=\"server\" OnClick=\"Button4_Click\" Text=\"Normal\" BackColor=\"#FF6600\" ForeColor=\"White\" \/&gt;&lt;\/td&gt;\n            &lt;\/tr&gt;\n            &lt;\/table&gt;\n        &lt;\/center&gt;\n    &lt;\/form&gt;<\/code><\/pre>\n\n\n\n<p>The design layout look like below screen :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"685\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-7.png\" alt=\"\" class=\"wp-image-3944\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-7.png 1020w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-7-600x403.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-7-300x201.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-7-768x516.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-7-585x393.png 585w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><figcaption class=\"wp-element-caption\">How to change Textbox borderwith, style and color in ASP.NET<\/figcaption><\/figure>\n\n\n\n<p>Now we have Three Button control one for Change the TextBox width, second for Change the Textbox Style and last one is for Change the Textbox Border color.<\/p>\n\n\n\n<p>Fist we change the Textbox Border color programmatically in ASP.NET C#.<\/p>\n\n\n\n<p>For change the Textbox bordercolor write below code in Button Click event:<\/p>\n\n\n\n<p>Now we will learn to change the border width of Textbox control in ASP.NET. write below code for change the Textbox border width in ASP.NET<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"684\" height=\"232\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-8.png\" alt=\"\" class=\"wp-image-3945\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-8.png 684w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-8-600x204.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-8-300x102.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-8-585x198.png 585w\" sizes=\"auto, (max-width: 684px) 100vw, 684px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void Button1_Click(object sender, EventArgs e)<br>{<br>TextBox1.BorderWidth = 10;<br>}<\/code><\/pre>\n\n\n\n<p>\u2013 Now last change the Textbox Style programatically in ASP.NET C#.<\/p>\n\n\n\n<p>\u2013 write this code for change the Textbox border style in Button Click Event.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"706\" height=\"243\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-9.png\" alt=\"\" class=\"wp-image-3946\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-9.png 706w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-9-600x207.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-9-300x103.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-9-585x201.png 585w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><figcaption class=\"wp-element-caption\">change Textbox BorderStyle in ASP.NET \u2013 ASP.NET Textbox Example<br><\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void Button2_Click(object sender, EventArgs e)\n{\nTextBox1.BorderStyle = BorderStyle.Double;\n}\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"234\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-10.png\" alt=\"\" class=\"wp-image-3947\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-10.png 708w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-10-600x198.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-10-300x99.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-10-585x193.png 585w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><figcaption class=\"wp-element-caption\">The ASP.NET Textbox border color change Result is:<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void Button3_Click(object sender, EventArgs e)<br>{<br>TextBox1.BorderColor = System.Drawing.Color.Orange;<br>}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"684\" height=\"219\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-11.png\" alt=\"\" class=\"wp-image-3948\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-11.png 684w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-11-600x192.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-11-300x96.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-11-585x187.png 585w\" sizes=\"auto, (max-width: 684px) 100vw, 684px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void Button4_Click(object sender, EventArgs e)\n{\nTextBox1.BorderColor = System.Drawing.Color.Black;\nTextBox1.BorderWidth = 1;\nTextBox1.BorderStyle = BorderStyle.Solid;\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u2013 Hi, In this ASP.NET Example we&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3949,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[84],"tags":[191],"class_list":["post-3943","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tipstricks","tag-asp-net"],"_links":{"self":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/3943","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=3943"}],"version-history":[{"count":3,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/3943\/revisions"}],"predecessor-version":[{"id":3969,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/3943\/revisions\/3969"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/media\/3949"}],"wp:attachment":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/media?parent=3943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/categories?post=3943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/tags?post=3943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}