I'm using ASP.NET 4.0 with Dynamic Data. Let's say I have an entity "Student" and it has a required column "DateOfBirth".
I can simply put RequiredAttribute to DateOfBirth metadata field, but I want to do better than that.
At the top of the page, i have "* - Indicates required field." At the field names, I want that column name to be "* Date of Birth".
But I only want the extra "*" to show up in Edit, Insert and Details page template. I don't want it to show in List template.
How do I do that?
I figured it out soon after posting this. I just need to modify Label_Init in EntityTemplates/Default_Edit.ascx.cs and Default_Insert.ascx.cs.
protected void Label_Init(object sender, EventArgs e)
{
Label label = (Label)sender;
if (this.currentColumn.IsRequired)
{
label.Text = "*";
}
label.Text += currentColumn.DisplayName;
}