Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
You do not need a custom property for this, just do like this:
[Display( Name = "StringLenghAttribute", Description = "StringLenghAttribute.", GroupName = "Validation tests", Order = 101)] [StringLength(10)] public virtual string StringLenghAttribute { get; set; }
David explains the validation attributes here:
http://www.david-tec.com/2012/06/EPiServer-7-Preview---Using-validation-attributes/
Hi all,
I am facing problem when creaing custom String property which MaxLength should only be 10. Even i run the project and Adding a property to template i could enter more than 10 characters. What may be the problem? Please look into the below code and tell me whether it is correct way or not. I have added the CustomControl in Models Folder.
TextPropertyCustom.cs
TextPropertyCustomControl.cs
using System;
using System.Collections.Generic;
using System.Text;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.Web.PropertyControls;
using EPiServer.Web.WebControls;
namespace MyDemo1.Models
{
/// <summary>
/// PropertyControl implementation used for rendering TextPropertyCustom data.
/// </summary>
public class TextPropertyCustomControl : EPiServer.Web.PropertyControls.PropertyStringControl
{
public TextPropertyCustom TextPropertyCustom
{
get
{
return PropertyData as TextPropertyCustom;
}
}
}
}
And one more query, Where i can exactly create this custom controls? Whether in Models folder or Models - Pages Folder?