TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nageshwar Rao
NA
74
37.5k
custom attribute to set string lenght dynamically
Sep 19 2016 11:34 AM
HI,
I want to set a string lenght for particular property by using custom attribute,i dnt want to set a constant string lenght
[Required(ErrorMessageResourceType = typeof(CampaignResource.VendorCampaign), ErrorMessageResourceName = "TitleRequired")]
[CustomValidation(typeof(VendorCampaignValidator), "ValidateName")]
[Display(Name = "Title", ResourceType = typeof(CampaignResource.VendorCampaign))]
public string Title { get; set; }///
public class VendorCampaignValidator : ValidationAttribute
{
public static ValidationResult ValidateName(string campaignName)
{
ResourceManager rm = new ResourceManager(typeof(InQuest.Sax.Resources.VendorCampaign));
if (string.IsNullOrWhiteSpace(campaignName))
return new ValidationResult(rm.GetString("TitleRequired"));
if (campaignName.Length <= VendorCampaignSettings.NameMaxLength)
{
return ValidationResult.Success;
}
else
{
return new ValidationResult(rm.GetString("InvalidLengthTitle"));
// return new ValidationResult(rm.GetString("Title should be at most 25 characters long"));
}
I am taking value from web.config file but it is not working
Reply
Answers (
1
)
Reading .xlsx file in c#
drop down id not getting if i give ng-repeat in mvc Angular