Click here to Skip to main content
16,016,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Friends,

I have some problem when i implimented project in mvc and c#.I checked username for unique name in database so i used remote validation in data annotation.Its great work in when i create new user but when i am trying to work on edit user then it will create problem and give me error username is already exists.please give me some solution as soon as possible.
Posted

1 solution

It sounds as though you're using the same view to do Create and Edit. If you are the solution is simple, don't do that.

Those are two separate operations that have differing validation requirements.

OR

You'r using separate views already and are using the same validation scheme for both. Don't. I can't tell you how separate that because you can do validation in multiple ways and you never said how your validation scheme is setup.
 
Share this answer
 
Comments
Member 8089110 3-Feb-16 23:21pm    
Sir,I want solution as soon as possible.I know that we have implement validation in multiple ways but i used remote validation for checking username is exists or not but its not work in edit properly so i want good solution asap.
Dave Kreskowiak 4-Feb-16 8:21am    
Excuse me but you might want to go back and re-read what I posted.

Nobody is here to follow your orders and give you exactly what you demand when you demand it.
Member 8089110 6-Feb-16 7:26am    
Sir,I have solve problem.thanks for giving me good guidelines
UnStable Messi 21-Jan-17 4:06am    
I'm also stucked in this problem of Remote validation. I think this is not good solution DAVE to create separate models for create and edit. if we implement Remote validation in create view for unique username and do not implement unique validation in Edit model. then user may put username in edit view which might be already exists in database so no validation is implemented that username will be saved to database
Dave Kreskowiak 21-Jan-17 10:32am    
First, don't hijack a thread that's a year old. Start you're own thread by posting your own question. Go to the "quick answers" menu and click on "Ask a Question".

Second, if you think using separate models is bad, then go ahead and struggle with your problem yourself. The requirements for models in a create and an edit operation CAN be different, very different. So, yes, using separate models for those two operations is quite reasonable.

Lastly, you're going to have to describe what you mean by "Remote validation". "Remote" is a relative term with respect to a viewpoint, which you never described.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900