Delete space in the name of an input

0

It's the following, I'm doing a foreach this way.

int count = 1;
@foreach (var item in Model)
    {
        <input name="itemId_@count" value="@item.ProdutoId" type="hidden">

        count++;
    }

The problem is that in processing the underline is processed together, and I needed it not to be processed, if I do it this way.

@foreach (var item in Model)
{
    <input name="itemId@count" value="@item.ProdutoId" type="hidden">

    count++;
}

The @count is not recognized.

I need an alternative to reference @count without having to use spaces or characters. Or some small script that clears space, but I have no idea if that's possible.

    
asked by anonymous 31.05.2018 / 21:15

1 answer

0

You need to use () keys next to @ .

@{
    int count = 1;
    foreach (var item in Model})
    {
        <input name="itemId@(count)" value="@item.ProdutoId" type="hidden">

        count++;
    }
}
    
04.06.2018 / 20:33