Client Id for Property (ASP.Net MVC)

Put this code somewhere: using System; using System.Linq.Expressions; using System.Web.Mvc; namespace MvcLibrary.Extensions { public static class HtmlExtensions { public static MvcHtmlString FieldIdFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression) { string htmlFieldName = ExpressionHelper.GetExpressionText(expression); string inputFieldId = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName); return MvcHtmlString.Create(inputFieldId); } } } Then in your ASPX view: <label for=”<%= Html.FieldIdFor(m => m.EmailAddress) %>”>E-mail address:</label> <%= … Read more

How to use JSF generated HTML element ID with colon “:” in CSS selectors?

The : is a special character in CSS identifiers, it represents the start of a pseudo class selector like :hover, :first-child, etc. You would need to escape it. #phoneForm\:phoneTable { background: pink; } This only doesn’t work in IE6/7. If you’d like to support those users as well, use \3A instead (with a trailing space … Read more

How to find out client ID of component for ajax update/render? Cannot find component with expression “foo” referenced from “bar”

Look in HTML output for actual client ID You need to look in the generated HTML output to find out the right client ID. Open the page in browser, do a rightclick and View Source. Locate the HTML representation of the JSF component of interest and take its id as client ID. You can use … Read more