{"id":3958,"date":"2022-12-17T03:08:38","date_gmt":"2022-12-17T03:08:38","guid":{"rendered":"https:\/\/isophal.com\/?p=3958"},"modified":"2022-12-17T03:11:28","modified_gmt":"2022-12-17T03:11:28","slug":"enable-textbox-disable-textbox-and-readonly-textbox-control-programmatically","status":"publish","type":"post","link":"https:\/\/isophal.com\/news\/2022\/12\/17\/3958.html\/","title":{"rendered":"Enable TextBox, Disable TextBox and ReadOnly TextBox Control programmatically"},"content":{"rendered":"\n<p>\u2013 Hi, Here we lean this asp.net tutorials, How to enable Textbox control, Disable TextBox control and Readonly Textbox control in ASP.Net C#.<\/p>\n\n\n\n<p>\u2013 First we have to Design the ASP.Net Page with One TextBox along with Theree(3) Button Server Control. The ASP.Net Enable, Disable, Readonly TextBox control Design Code is below :<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u2013 write below code in head body tag:-<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&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;Enable TextBox, Disable TextBox and ReadOnly TextBox Control programmatically&lt;\/h3&gt;\n                &lt;p&gt;\n                    &lt;asp:Image ID=\"Image1\" runat=\"server\" ImageUrl=\"images\/final_logo_isophal_white.png\" Width=\"220px\" \/&gt;\n                &lt;\/p&gt;&lt;\/td&gt;\n            &lt;\/tr&gt;\n            &lt;tr&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;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=\"Enable\" BackColor=\"#FF6600\" ForeColor=\"#FFFF66\" Height=\"35px\" Width=\"120px\" Font-Bold=\"True\" \/&gt;\n            &amp;nbsp;&lt;asp:Button ID=\"Button2\" runat=\"server\" OnClick=\"Button2_Click\" Text=\"Disable\" BackColor=\"#FF6600\" ForeColor=\"#FFFFCC\" Height=\"35px\" Width=\"120px\" Font-Bold=\"True\" \/&gt;\n            &amp;nbsp;&amp;nbsp;&lt;asp:Button ID=\"Button3\" runat=\"server\" OnClick=\"Button3_Click\" Text=\"ReadOnly\" BackColor=\"#FF6600\" ForeColor=\"#FFFFCC\" Height=\"35px\" Width=\"120px\" Font-Bold=\"True\" \/&gt;\n                &lt;\/td&gt;\n            &lt;\/tr&gt;\n            &lt;\/table&gt;\n        &lt;\/center&gt;\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"697\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-17-1024x697.png\" alt=\"\" class=\"wp-image-3959\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-17-1024x697.png 1024w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-17-600x408.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-17-300x204.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-17-768x522.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-17-1170x796.png 1170w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-17-585x398.png 585w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-17.png 1226w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Write below code for Enable TextBox:<\/strong><\/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-18-1024x538.png\" alt=\"\" class=\"wp-image-3960\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-18-1024x538.png 1024w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-18-600x315.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-18-300x158.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-18.png 1200w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-18-768x403.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-18-1170x614.png 1170w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-18-585x307.png 585w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void Button1_Click(object sender, EventArgs e)<br>{<br>TextBox1.Enabled = true;<br>}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"654\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-19-1024x654.png\" alt=\"\" class=\"wp-image-3961\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-19-1024x654.png 1024w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-19-600x383.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-19-300x191.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-19-768x490.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-19-1170x747.png 1170w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-19-585x373.png 585w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-19.png 1222w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><strong>write below code for Disable TextBox:-<\/strong><\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void Button2_Click(object sender, EventArgs e)<br>{<br>TextBox1.Enabled = false;<br>}<\/code><\/pre>\n\n\n\n<p><strong>Write below code for ReadOnly TextBox:-<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>protected void Button3_Click(object sender, EventArgs e)<br>{<br>TextBox1.ReadOnly = true;<br>}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"838\" height=\"421\" src=\"https:\/\/isophal.com\/wp-content\/uploads\/2022\/12\/image-20.png\" alt=\"\" class=\"wp-image-3962\" srcset=\"https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-20.png 838w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-20-600x301.png 600w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-20-300x151.png 300w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-20-768x386.png 768w, https:\/\/isophal.com\/news\/wp-content\/uploads\/2022\/12\/image-20-585x294.png 585w\" sizes=\"auto, (max-width: 838px) 100vw, 838px\" \/><figcaption class=\"wp-element-caption\">ReadOnly TextBox in ASP.Net<br><br><\/figcaption><\/figure>\n\n\n\n<p>\u2013&nbsp; Here, we learnt problematically Enable, Disable, ReadOnlyTextbox control in ASP.Net TextBox Example.<\/p>\n\n\n\n<p>\u2013 The same things we can do without Problematically like this:<br>Just SET the TextBox Property<strong>&nbsp;Enabled = True \/ False<\/strong>&nbsp;for Enable \/ Disable Textbox Control.<\/p>\n\n\n\n<p>For ReadOnly SET TextBox Property&nbsp;<strong>ReadOnly = True \/ False<\/strong>&nbsp;for ReadOnly on\/off Textbox.<\/p>\n\n\n\n<p>\u2013 In above ASP.Net Tutorials, we have learn&nbsp; How to enable Textbox control, Disable TextBox control and Readonly Textbox control in ASP.Net C#.<\/p>\n\n\n\n<p>\u2013 I hope, will enjoy this&nbsp; ASP.Net TextBox Example of&nbsp; Enable, Disable, Readonly TextBox control of asp.net.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u2013 Hi, Here we lean this asp.net&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3960,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[189,140],"tags":[191],"class_list":["post-3958","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\/3958","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=3958"}],"version-history":[{"count":2,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/3958\/revisions"}],"predecessor-version":[{"id":3965,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/posts\/3958\/revisions\/3965"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/media\/3960"}],"wp:attachment":[{"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/media?parent=3958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/categories?post=3958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/isophal.com\/news\/wp-json\/wp\/v2\/tags?post=3958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}