Robert Wagner
Robert Wagner

Reputation: 11

MVC3 Html.BeginForm not rendering for a page

I have a web page (one of many). But on this particular web page the following doesn't render.

@using (Html.BeginForm()) {
     <h1>bbbbbbbbbbbbbbbbbbbbbbbbbbbb</h1>
 }

The only difference between this and other web pages is that I have dynamically created this link to this page with jQuery rather than hardcoding the link on the page. When I check the link it looks like this:

<a href="/adminStats/Edit?PartitionKey=P22&amp;RowKey=01-01-0001">Edit</a>

Is there something about BeginForm that can't see the page address so it doesn't create the form link?

Robert

Upvotes: 1

Views: 1979

Answers (2)

Aman Mahajan
Aman Mahajan

Reputation: 161

I had the same problem. Check for nested form tags.

Upvotes: 9

Gup3rSuR4c
Gup3rSuR4c

Reputation: 9488

I'm assuming that if you don't specify the route values, BeginForm will try to create the form action based on the current request context. That being said, if that's not the current view's URL then it shouldn't matter. So, in the end, I would say that that link has no effect on BeginForm, but something that BeginForm needs from behind the scenes (out of your control) is not available, and thus BeginForm is silently failing.

You can try exploring the source for BeginForm and see what potentially might be missing...

Upvotes: 0

Related Questions