-1

I have an cshtml problem: i have this snippet:

  @for (int i = 0; i < 25; i++)
               {
                <tr>
                <td>
                        <input class="myCell" type="text" name ="num"@i/>
                </td>
                <td>
                    <input class="myCell" type="text" name="client"@i/>
                </td>
                <td>
                   <input class="myCell" type="date" name ="reception"@i/>
                </td>
                <td>
                    <input class="myCell" type="date" name="cloture"@i/>
                </td>
            </tr> 
               }

and i'd like to rename the first inputs num0, client0..... until the last inputs num23, client23 ..., i try the snippet above but it didn't work.

Why the code didn't work? How can i fix it?

4

2 回答 2

2

Try putting the variable inside the double quotes and put it in parenthesis:

<input class="myCell" type="text" name ="num@(i)"/>
<input class="myCell" type="text" name="client@(i)"/>
...
于 2013-08-26T14:08:48.690 回答
2

It sounds like you want to write

name="num@(i)"

The parentheses are necessary to prevent Razor from thinking it's an email address and ignoring it.

于 2013-08-26T14:08:53.973 回答