I was wondering why enclose @Html.BeginForm() in @using block like below. Does it matter if I don't use @using block?
@using (Html.BeginForm())
{
}
Does it matter if I don't use @using block?
Yes, it will matter. The BeginForm method returns an IDisposable and in its Dispose method it renders the closing </form>
tag. So if you don't place it in a using
statement you will have to generate the closing form tag yourself:
@Html.BeginForm()
...
@Html.EndForm()
which is uglier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With