Sebastian K
Sebastian K

Reputation: 6373

Allowing user to change private piece of information on ASP.NET MVC 3 form

On an ASP.NET MVC 3 form we have a field that contains private account number that we never display to user, and we do not store it in our system (we pass it to back-end system one-way). We only know if it was previously provided or not. User sometimes may choose to modify the value, so we display it as follows:

@Html.PasswordFor(x => x.Private, new { id = "txtPrivate" })

Then if we receive the field as empty, we know user did not change anything. It works fine, but is slightly confusing to user, as he sees the field as empty on UI. Ideally we would like to show few dots to indicate to user something has been entered before, and can be changed. What would be the best way of doing that?

I think simple workaround would be to send five-letter "magic" value to UI, and then compare the model on the post, but that is obviously not a nice solution.

Upvotes: 0

Views: 74

Answers (1)

Dima
Dima

Reputation: 6741

Strange requirement requires strange solution, what if you'll use placeholder for this:

@Html.PasswordFor(x => x.Private, new { id = "txtPrivate", placeholder="*******" })

it's value will not be submitted to the server as far as I know.

Everybody except bloody IE supports it, but there are workarounds for this.

Upvotes: 1

Related Questions