<p>I'm trying to implement something like this:</p>

<pre><code>&lt;div&gt;
    &lt;table&gt;
        &lt;thead&gt;
            &lt;tr&gt;
                &lt;td&gt;Port name&lt;/td&gt;
                &lt;td&gt;Current port version&lt;/td&gt;
                &lt;td&gt;New port version&lt;/td&gt;
                &lt;td&gt;Update&lt;/td&gt;
            &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;% foreach (var ip in Ports) { %&gt;
            &lt;tr&gt;
                &lt;td&gt;
                    &lt;%= ip.PortName %&gt;
                &lt;/td&gt;
                &lt;td&gt;
                    &lt;%= ip.CurrentVersion %&gt;
                &lt;/td&gt;
                &lt;td&gt;
                    &lt;%= ip.NewVersion %&gt;
                &lt;/td&gt;
                &lt;td&gt;
                    &lt;asp:Button ID="btnUpdate" runat="server" Text="Update" CommandArgument="&lt;% ip.PortName %&gt;" /&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;% } %&gt;
    &lt;/table&gt;
&lt;/div&gt;
</code></pre>

<p>The button's <code>CommandArgument</code> property is where my code complains about not being able to resolve symbol <code>ip</code>. Is there any way to do what I'm trying to do?
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>

[{'answer_id': 17024, 'author': 'Andrew Rimmer', 'author_id': 1982, 'author_profile': 'https://Stackoverflow.com/users/1982', 'pm_score': 3, 'selected': True, 'text': "<p>You don't want to use a Webforms button in ASP.NET MVC. MVC is a completely different way of working, and you no longer have the WebForms abstraction. </p>\n\n<p>You have 2 different options you can either replace your asp:Button with an input tag or use a standard hyperlink instead. If you use the input option then you will need to wrap in a form element. The form action should point to a Controller action.</p>\n"}, {'answer_id': 594453, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>I think you have to enclose your block in Form tags ans runat=server.</p>\n'}, {'answer_id': 594544, 'author': 'Spoike', 'author_id': 3713, 'author_profile': 'https://Stackoverflow.com/users/3713', 'pm_score': 1, 'selected': False, 'text': '<p>You can\'t use webform controls in ASP.NET MVC in a trivial manner because they rely on things that are stripped out in MVC. Instead you add a button in two ways, both using the <code>HtmlHelper</code> on the <code>ViewPage</code>:</p>\n\n<p>You can add a button in a form, which is easily handeled in a controller if you have a form for each single button:</p>\n\n<pre><code>&lt;% using(Html.BeginForm("Update", "Ip", new {portName = ip.PortName} )) { %&gt;\n\n    ....\n    &lt;input name="action" type="submit" value="Update"&gt;\n\n&lt;% } %&gt;\n</code></pre>\n\n<p>BeginForm() will default to the same controller and action as the view was created from. The other way is to add a link instead, which is more fitting to your example of iterating through a list. For example lets say you have IpController</p>\n\n<pre><code>&lt;%= Html.ActionLink("Update IP", "Update", "Ip", \n        new { \n            portName = ip.PortName \n        }) \n%&gt;\n</code></pre>\n\n<p>The link will go to the Update action in IpController with the given portName as parameter. In both cases you\'ll need this action in IpController:</p>\n\n<pre><code>public ActionResult Update(string portName) {\n    // ...\n}\n</code></pre>\n\n<p>Hope this helps.</p>\n'}, {'answer_id': 927692, 'author': 'Tim Rourke', 'author_id': 114451, 'author_profile': 'https://Stackoverflow.com/users/114451', 'pm_score': 0, 'selected': False, 'text': '<p>FWIW,</p>\n\n<p>I think this text is missing an equals sign:</p>\n\n<p>CommandArgument="&lt;% ip.PortName %>"</p>\n\n<p>Should be</p>\n\n<p>CommandArgument="&lt;%= ip.PortName %>"</p>\n'}]
['https://Stackoverflow.com/questions/16964', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/614/']