5
I have a loop inside my cshtml file. This loop has a variable i
and I use it to compose a name according to her position in the loop, like txtNome1
, txtNome2
, txtNome3
and so on.
I need to make the variable composed with zeros on the left so that the name smaller than 10 looks like this: txtNome01
, txtNome02
, txtNome03
and so on.
How to do this inside the loop in the file cshtml
? My problem is how to use it. See below part of my for(loop). I need to compose the variables that will complete the name.
string
nm,dia,mes,ano,sexo,numpassaporte,
diavalidade, mesvalidade,
anovalidade, paisemissao = "";
for (int i = 1; i < 3; i++)
{
nm = "txtNome" + i;
dia = "txtDia" + i;
mes = "txtMes" + i;
ano = "txtAno" + i;
sexo = "txtSexo" + i;
numpassaporte = "txtPassaporte" + i;
diavalidade = "txtDiaVal" + i;
mesvalidade = "txtMesVal" + i;
anovalidade = "txtAnoVal" + i;
paisemissao = "txtPaisEmissao" + i;
I spoke Javascript, but it can be anything, as long as it’s not in code Behind to give more performance to the site.
If you found your answer mark one of them as a solution to your problem..
– fernandosavio