mvc3 and mvc2

Sep 18, 2011 at 9:37 PM
Edited Sep 18, 2011 at 9:55 PM

Hi Omu,

Great project! The implementation looks clean. I just started learning mvc 3, so I migrated the project to be mvc3. The JQuery script seems have trouble with the response from the controllers, when I add the first root question, it works fine, but not the second one. The reason seems to be somehow it couldn't keep all values for RootCreateInput created in the JQuery form, so when it does the post to public ActionResult AddRoot(RootCreateInput input), the input.RCType is null, which in turn cases exception.

id = service.Create(null, Utils.ReadInt32(input.RCType), input.RCText, input.RCSurveyId, input.RCIsMandatory);

 

I tried to change the form option: resetForm:false, it then seems be able to keep the complex value as well(with all state though, which is not desired, but just try to find the problem). Would you be able to enlighten something here? restForm:true shouldn't be the root cause, I also see something else broken such as Editing a survey, it goes to database and get the survey, but when the view renders it, it somehow show the content directly instead rendering it. Anything different between mvc3 and mvc2?

Thanks for ideas / suggestions,

--dk

Sep 19, 2011 at 9:48 PM

Hi Omu,

The problem is when JQuery form is submitted, RCType value or QCType value could not be populated properly in the returning RootCreateInput parameter. Using resetForm:false could bypass the problem, but not sure why mvc2 works fine.

Actually, do you recall why you used

public object RCType { get; set; }

 instead

 

public IEnumerable<SelectListItem> RCType { get; set

; }

in the view tamplate?

-dk.

Coordinator
Sep 20, 2011 at 9:37 AM
Edited Sep 20, 2011 at 9:38 AM

it's object because I was sending an IEnumerable<SelectListItem> and getting back just the value of the selected item (int I think )

probably the model binding is different in mvc2

I don't use this technique anymore, because all my dropdowns are AjaxDropowns from Project Awesome

Sep 24, 2011 at 3:06 PM

yes, and the string needs to be MvcHtmlString otherwise it will be encoded etc. But anyway, I found your Project Awesome is good, that is an awesome project. thank you for you answer.

-dk