Skip to content

Counting Textbox Control

Sidhartha Patnaik

Sidhartha Patnaik

Asked Apr 3, 2017, 10:45 PM EDT7 answers
Share
LinkedInX
Hello sir, I am developing a project on question bank system. And I want to show the statistics that how many questions asked, how many questions attended, how many right and wrong. The answer should be fill up in textbox control. thats why I want to count the number of textbox control.
 
 Thanking you
Sidhartha Patnaik 

6 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Prafulla Sahu
    0
    If you are simply counting the number of textbox present in a container then you  can refer the below code.
    1. int i = 0; // For counting the number of textbox  
    2. foreach (Control control in Panel1.Controls)  
    3. {  
    4.   if(control is TextBox)  
    5.   {  
    6.      ++i;  
    7.   }  
    8. }  
     Let me know if you have any other concern
    0
  • Sidhartha Patnaik
    0
    Thanks 
    Prafulla Sahu sir,
    But it is showing answer as 0.
    I have 2 textbox controls. 
    0
  • Prafulla Sahu
    0
    Let's dig more
     
    1. you have to find out the container name present in your web page which contain all your textbox controls. here Panel1
     
     
     
     2. Now we came to know that this is the control which holds all my textbox controls. let's code then, instead of Panel1 use your container name.
     
     
     
     
    try once and let me know if got the hint.
    0
  • Sidhartha Patnaik
    0
    Thank you so much Prafulla Sahu sir.. Its working fine.
    0
  • Sidhartha Patnaik
    0
    Now How Can I count the textbox which are null and which are not null ?
    0
  • Prafulla Sahu
    0
    Please have a look on the below changed code. I am sorry for late reply coudn't had a chance to look on your reply.
    0
  • 1 short reply
    • Sidhartha Patnaik
      0
      thanks prafulla sir
      0