Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I have an entry form where some fields are mandatory so displaying asterix sign there(*).
Now I have a requirement to change Font-color of all the fields marked with asterix to RED Color. I have a code block where I am displaying asterix if the field is required. I am not getting how to modify it to change the font-color to RED. Below is the code:-
C#
public static DoubleDiv BeginControlGroupForWorkType(this HtmlHelper htmlHelper, string controlId, string label, bool isRequired, WorkEffort workEffort)
       {
           string validationHTML = GetValidationMessage(htmlHelper, controlId, label, Enums.WorkEffortTab.None);
           if (string.IsNullOrEmpty(validationHTML))
               validationHTML = GetValidationMessageForWorkType(htmlHelper, controlId, workEffort);

           htmlHelper.ViewContext.Writer.Write(string.Format(@"
               <div class=""control-group"">
                   {0}
                   <label class=""control-label"" for=""{1}"">{2} {3}</label>
                   <div class=""controls"">",
               validationHTML,
               controlId,
               isRequired ? "">*" : string.Empty,
               label));

           return new DoubleDiv(htmlHelper.ViewContext);
       }

Can anybody please help me in this.

Thanks
Fozia

What I have tried:

I am trying to modify the existing Required class but it is not impacting the label. I also tried putting isRequired line again but how to modify the existing label with that condition, because label is already created above that isRequired condition.
Posted
Updated 30-Mar-16 20:16pm
v3
Comments
Sergey Alexandrovich Kryukov 31-Mar-16 2:11am    
Create different CSS classes and change the element's class, to recolor it.
—SA
Passion4Code 31-Mar-16 2:41am    
Good one..:D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900