Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unique validation
Message
 
 
À
28/12/2012 13:16:47
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01560641
Message ID:
01560835
Vues:
39
>>However, ViewBag.ClientId returns null and so immediately after I fire that form it comes up with the Client No aleady exists message.
>>
>>Do you see how can I solve this problem?
>>
>>Thanks in advance.
>
>Bit hard to see where Number / ClientId comes from.
>
>But if, for example, ClientId is a control on the form then you can use the 'AdditionalFields' property of the Remote attribute when validating the name. Something like:
[Remote("doesClientNameExist", "Account",AdditionalFields = "ClientId")]
and
   public JsonResult doesClientNameExist(string UserName, string ClientId)
>    {
>        //.......
>    }
then you'll have both properties available. Don't know if this is what you were looking for tho :-{
>
>Also, without looking more, I've no suggestions as to why the validation fires on keypress......

This is what I have right now
public class ClientViewModel
    {
        public Client Client { get; set; }

        [Required]
        [DisplayName("Client No")]
        [UIHint("Number")]
        [Column("client_no", TypeName = "smallint")]
        [Remote("doesClientNoExist", "Client", HttpMethod = "POST", ErrorMessage = "Client Number already exists. Please enter a different Client Number.")]
        public virtual Int16 Number 
        {
            get { return Client.Number; }

            set { Client.Number = value; }
        }

        [Required]
        [Column("client_name", TypeName = "varchar")]
        [DisplayName("Client Name")]
        [MaxLength(30, ErrorMessage = "Client Name should not be longer than 30 characters")]
        [MinLength(3, ErrorMessage = "Client Name is too short")]
        [Remote("doesClientNameExist", "Client", HttpMethod = "POST", ErrorMessage = "Client Name already exists. Please enter a different Client Name.")]
        public virtual string Name
        {
            get { return Client.Name; }

            set { Client.Name = value; }
        }

        public int id { get; set; }
    }
}
Can you clarify how should I change it?

Thanks a lot again.

For validaions problems I posted it here
http://forums.asp.net/p/1869270/5252771.aspx/1?p=True&t=634922954745355214

This post shows all my current code.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform