Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Topics

Recent Status Updates

View All Updates

- - - - -


asp.net mvc c#

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 Apprentice123


    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 457 posts

Posted 08 July 2016 - 07:55 AM

I created a class in order to learn about annotation in asp.net. This is my class:

using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace MvcMusicStore.Models
    [Bind(Exclude = "AlbumId")]
    public class Album
        public int AlbumId { get; set; }

        public int GenreId { get; set; }

        public int ArtistId { get; set; }

        [Required(ErrorMessage = "An Album Title is required")]
        public string Title { get; set; }

        [Required(ErrorMessage = "Price is required")]
        [Range(0.01, 100.00,
            ErrorMessage = "Price must be between 0.01 and 100.00")]
        public decimal Price { get; set; }

        [DisplayName("Album Art URL")]
        public string AlbumArtUrl { get; set; }

        public virtual Genre Genre { get; set; }
        public virtual Artist Artist { get; set; }

But the [DisplayName("Genre")] and [DisplayName["Artist")] aren't working. Also, the Client-Side Validation is not working. When a field is required and I start typing in this field the require message still showing. Where are the problems?

#2 lespauled


    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts

Posted 08 July 2016 - 10:45 AM

In order to see why something is or isn't working, we need the view also.

My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download