Leah
Leah

Reputation: 15

Confirm email doesn't work in asp.net mvc

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.ComponentModel.DataAnnotations;
 using WebValidation.Common;
 using System.Web.Mvc;

 namespace WebValidation.Models
{
    [MetadataType(typeof(EmployeeMetaData))]
    public partial class Employee
    {
    [System.Web.Mvc.Compare("Email")]

    public string ConfirmEmail { get; set; }
    }

This is my code for confirming email address, but after I run my application, the confirm email always say that it doesn't match with email address. Although I have copy email and paste on confirm email, it still said not match!

Anyone tell me what's the problem?

Upvotes: 0

Views: 341

Answers (1)

Ryan Metin
Ryan Metin

Reputation: 899

I'm new to asp.net, but I think the CompareAttribute class is in the System.ComponentModel.DataAnnotations namespace. Your annotation should just be:

[Compare("Email")]
public string ConfirmEmail { get; set; }

Upvotes: 0

Related Questions