Reputation: 175
Is there any way to create the name variable in an input text field with a c# variable in it?
So something like:
<input type="text" name="Status + @i" value="" />
I tried a few different combinations:
name="'Status' + '@i'"
name = "Status" + @i
but none of them worked after submitting.
Upvotes: 0
Views: 910
Reputation: 71
Also
@('Status' + i.ToString())
OR
<input type="text" name="Status@(i)" value="" />
I think works too
should work too, String.Format is more flexible, however.
Upvotes: 0
Reputation: 5895
Use String.Format() :
name="@String.Format("Status{0}", i)"
or directly
name='Status@i'
Upvotes: 3