Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: How to change color of tag in Custom Html Tag in MVC5

vicky:

I have a Custom Html Helper class like this below,


public static class LabelWithAstrickHelper
{
public static MvcHtmlString LabelWithAstrick(this HtmlHelper html, Expression> expression, object htmlAttributes)
{
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
string resolvedLabelText = metadata.DisplayName ?? metadata.PropertyName;
if (metadata.IsRequired)
{
resolvedLabelText += "*";
// resolvedLabelText += "*";
}
return LabelExtensions.LabelFor(html, expression, resolvedLabelText, htmlAttributes);
}
}

I used it like below in my view.


@Html.LabelWithAstrick(model => model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })

Now this will Show 'astrick' in black color, but I want to display this 'astrick' sign in red color.

please suggest How to do this.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: How to change color of tag in Custom Html Tag in MVC5

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×