title: ID Being Rendered As Null In A Typed Razor View
body: <p>This is really weird, for some reason the Id of the ViewModel is being rendered as null inside the view. I debugged the application and checked that the view model is actually being mapped correctly (using AutoMapper) and everything is fine. But when I do @Model.Id, it is rendering as zero, and when I alert the value using jQuery I get "null". So what's going on?</p>
  
  <pre><code>            &lt;div id="commentBox"&gt;
                  @using (Html.BeginForm("Comment", "Item", new { itemId = Model.Id  } ))
                  {
                      &lt;span class="greenText"&gt;answer&lt;/span&gt;
                      &lt;span id="hiddenForId"&gt;@this.Hidden(x =&gt; x.Id).Id("idPlaceHolder")&lt;/span&gt;
                      &lt;span id="commentInputBox"&gt;@this.TextBox(x=&gt;x.CommentText).Id("commentField")&lt;/span&gt;
                      &lt;span id="commentButton"&gt;@this.SubmitButton("").Id("commentSubmit").Class("okButton")&lt;/span&gt;
                  }
              &lt;/div&gt;
  
          &lt;div style="clear:both"&gt;&lt;/div&gt;
      &lt;/div&gt; 
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      $(function () {
          alert($("idPlaceHolder").html());
          $("#commentSubmit").click(function () {
              var dataObj = { 'commentText': $("#commentField").val(), 'itemId': $("idPlaceHolder").html() }
              $.ajax({
                  url: '/Item/Comment',
                  data: dataObj,
                  type: 'POST',
                  success: function (result) {
                      if (result.redirectTo != null &amp;&amp; result.redirectTo != '') {
                          window.location.href = result.redirectTo;
                      } else {
                          alert(result.error);
                      }
                  }
              });
              return false;
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>P.S: on a side note, how do you tell the form that it doesn't need to post and that it has been taken care of? I just cannot remember it... It's definitely something other than <code>return false;</code></p>