I need to remove a control (a textbox) from my page when a certain condition is verified.
Is it possible to do from code-behind or I need to use JavaScript.
NOTE I need to remove the control, not to hide…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
Controls.RemoveorControls.RemoveAton the parentControlCollection.For example, if you want to remove all TextBoxes from the page’s top:
(note that you need to add
using System.LinqforEnumerable.OfType)or if you want to remove a TextBox with a given ID:
If you just want to hide it (and remove it from clientside completely), you can also make it invisible: