views:

133

answers:

2

I've got an MVC app that gives the user textarea's to update some description fields. It's strongly-typed to a table object, and the fields are wrapped in a form with a Submit button.

Occaisionally they don't want any data in a field, but when they delete the text and try to save, the blanked-out field comes back with its original text (i.e. the table object passed to the Save action contains other edits, but attempts to blank out fields result in the original text staying in the field).

I'm assuming this is LINQ trying to determine which fields have been edited, but how do you tell it that it's blank on purpose?

UPDATE: It appears this may be a problem with the TinyMCE jQuery plugin. It adds rich-text functionality to textarea controls. If I turn it off, I can remove text with no problems.

UPDATE 2: It seems to be some kind of javascript bug or something. If I put another dummy field after the problem fields, they work. If I move them to another place in my code, they work. They just don't want to work where they are. Very peculiar.

A: 

I'm pretty sure that TinyMCE, by default, puts in <p></p> when the control is emptied.

So if you are checking for "" then you may be disapointed.

This initially caused me some issues but never with saving. I was checking if the field was "" and then doing something else. Once I realised that "" was never going to happen, I adapted my validation accordingly.

griegs
A: 

I just check that on a recent project using TinyMCE editor, but it indeed send "" for an empty input, and during the implementation we had no issues with that.

alt text

The body property is the one with a tinyMCE editor on the client side.

I really think it will be something with the modelBinder or the way you set the values back to the model.

Omar