title: @Html.BeginForm not working under the @If statement in Razor Code
body: <p>Below is my razor code:</p>
  
  <pre><code>&lt;div class="col-md-7 col-md-offset-5"&gt;
  @if (Model.InvoiceStatus == "NEW")
  {                                                                              
      Html.BeginForm("Delete", "Invoices", new { InvoiceID = Model.InvoiceID, @returnUrl = Url.Action(ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["controller"].ToString()) }, FormMethod.Post);
  
      @Html.AntiForgeryToken()
      &lt;input type="submit" value="Delete Invoice" class="btn btn-danger newbtn" style="float:right;margin-left:10px;" onclick="return confirm('Are you sure to delete this Invoice details?');" /&gt;
  
      Html.EndForm();
  
      @Html.ActionLink("Lock Invoice", "Lock", new { InvoiceID = Model.InvoiceID }, new { @class = "btn newbtn", @style = "float:right;margin-left:10px;" })
  
      @Html.ActionLink("Edit Invoice", "Edit", new { InvoiceID = Model.InvoiceID }, new { @class = "btn newbtn", @style = "float:right;margin-left:10px;" })
  
  }
  
      @Html.ActionLink("Back", "Index", null, new { @class = "btn btn-default newbtn", @style = "width:100px;float:right;" })
  &lt;/div&gt;
  </code></pre>
  
  <p>The code didnt recognize the html.beginform, it just renders as input tag,</p>
  
  <pre><code>&lt;input value="Delete Invoice" class="btn btn-danger newbtn" style="float:right;margin-left:10px;" onclick="return confirm('Are you sure to delete this Invoice details?');" type="submit"&gt;
  </code></pre>
  
  <p>Why it is not rendering as form?</p>