Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 633727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:13:03+00:00 2026-05-13T20:13:03+00:00

ASP.NET MVC 2.0: Simple Model Binding not working/binding as it should i have a

  • 0

ASP.NET MVC 2.0: Simple Model Binding not working/binding as it should

i have a simple custom object names Comment (linq to sql generated one), it has various values, but only two values are being sent from a HTML POST from to my action, and here is my action that accepts them…

 Function InsertComment(ByVal Comment As Comment) As ActionResult  
              ' both CommentForPicID As Integer and Comment As String are the two values sent.

 End Function

The textarea is named using the TextAreaFor and the hidden id with HiddenFor, and i have checked to make sure the property names of my Comment object match exactly (case and all) with the HTML ID/Name values of the FORM elements, both are CommentForPicID and Comment without any prefixes.

i have a breakpoint on my action to see whats going on, When my action receives it, the Comment object is always set to Nothing, throughout the action, and eventually an exception is thrown as i’m trying to use a null object.

i have read steven sandersons MVC framework’s model binding section, everything should be in order, does anyone have any ideas?

.
.
.

Additional information (reading not required):
however the interesting thing is, if i wrap the Comment object up in a parent object, say, CommentsParent with contains some stuff & the Comment object as variables… then i of course change the form elements id’s with the apporpriate prefixes, it then works as prescribed… but i did this just to test that binding was working, and dont want/need to do this for my application.

here is the markup for anyone who wants to see it:

<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of FP.Comment)" %>

<%@ Import Namespace="FP" %>

<%--The line below is a workaround for a VB / ASPX designer bug--%>
<%=""%>
<% Html.EnableClientValidation()%>

<% Using Ajax.BeginForm("InsertComment", "Home", New AjaxOptions With {.UpdateTargetId = "InsertComment", .HttpMethod = FormMethod.Post})%>

   <%= Html.HiddenFor(Function(x) x.CommentForPicID)%>

   <%= Html.TextAreaFor(Function(x) x.Comment, 8, 40, New With {.style = "overflow: hidden;"})%><br />

   <%= Html.ValidationMessageFor(Function(x) x.Comment)%>


  <input type="submit" value="Save" name="SaveCancelButton"/>
  <input type="submit" value="Cancel" name="SaveCancelButton" />

<% End Using %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:13:04+00:00Added an answer on May 13, 2026 at 8:13 pm

    The problem is that your model class is named Comment and inside you have a string property also called Comment that you try to bind to the textarea. This doesn’t work as the binder is getting confused. Either use a bind prefix or rename the property or the class so that they are different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 353k
  • Answers 354k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have a look here: http://msdn.microsoft.com/en-us/library/ms788718.aspx#workflow_to_localize You'll probably need to put… May 14, 2026 at 7:51 am
  • Editorial Team
    Editorial Team added an answer Does the example above work when you declare the original… May 14, 2026 at 7:51 am
  • Editorial Team
    Editorial Team added an answer If the target you are testing is an application, you'll… May 14, 2026 at 7:51 am

Related Questions

I am looking for some guidance on how to incorporate business rules into an
This is more of an open question. What is your opinion on query strings
I'm using Mono 2.4 on the Ubiquity web hosting service. I created a simple
I was playing with ASP.NET MVC 1.0 a couple of days ago. I started
I am using ASP.NET MVC 1.0. I have an ActionResult which receives a form

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.