How to join the name in textbox with a variable using VB.Net

admin

Administrator
Staff member
how to join the name in textbox with a variable using VB.Net ?

for example :it have 10 textbox with name txtFrom1 to txtFrom10

so how to join the number with the txtFrom

x = 1

while (x < 11)
x+= 1
like "txtFrom" + x.toString
end while

thanks !!!Why do you want to do that? Do you want to create the tectbox controls in run-time?If there is always gonna be 10 fields, you could do it manually. If you wanna do it dynamically like dev said, you could so something like this


//NOT real code, just showing you so u get the idea
pageLoad()
{
if(!PostBack())
{
int Number = Request.'getPram' ("numerOfBoxes");

(hidden field) numOf;
numOf.Text = 10;
numOf.ID = "numerOfBoxes";
Page.Controls.Add(numOf);

for(i -> Number)
{
newBox - Request.'getPram' ("BoxNum"+i);
array = newBox;
}
}
else
{
for(a -> howMnayUwant)
{
TextBox tb = new TextBox()
tb.ID = "BoxNum"+a;
Page.Controls.Add(tb);
}
}
}


It's not the most elegant way, but the only way i could think of.

If you want this then i can look on my HD for the real code, but if it's not what your after or someone provides a better solution then i saved me a search.thanks for all of you !
 
Back
Top