forum

Home / DeveloperSection / Forums / Can I loop through textbox id’s to check values in asp.net

Can I loop through textbox id’s to check values in asp.net

Pravesh Singh 1992 14-Nov-2014

I'm working on a project and I'm a beginner and I'm having a little trouble with this. I'm trying to check if a textbox is empty and if it is to change the value to N/A so that I can input n/a into a database instead of it not working.

Here is the code that I thought would work but didn't because the .Text property isn't near the ID anymore:

for(int i = 1; i<=17; i++)
{
if(!("tb" + i).Text)
"tb" + i.Text = "n/a";
}

I wasn't sure if the true/false would work but I never got to find out because it doesn't compile to begin with. I have 17 textboxes on my design page all with ID 'tb + i' e.g tb1, tb2


Updated on 14-Nov-2014

Can you answer this question?


Answer

1 Answers

Liked By