本文整理汇总了C#中IElement.GetAttr方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.GetAttr方法的具体用法?C# IElement.GetAttr怎么用?C# IElement.GetAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.GetAttr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoExecute
protected override void DoExecute(IElement element)
{
var htmlHelper = htmlHelperFunc();
if (!ClientValidationEnabled(htmlHelper) && !SupportsModelState(element))
return;
var unobtrusiveValidationAttributes = htmlHelper.GetUnobtrusiveValidationAttributes(element.GetAttr("name"));
foreach (var attribute in unobtrusiveValidationAttributes)
{
element.SetAttr(attribute.Key, attribute.Value);
}
}
示例2: Execute
public void Execute(IElement element)
{
var name = element.GetAttr(HtmlAttribute.Name);
var supportsModelState = element as ISupportsModelState;
if(name == null || supportsModelState == null)
{
return;
}
ModelState state;
if(modelStateDictionaryFunc().TryGetValue(name, out state) && state.Errors != null && state.Errors.Count > 0)
{
element.Builder.AddCssClass(validationErrorCssClass);
if(state.Value != null)
{
supportsModelState.ApplyModelState(state);
}
}
}
示例3: DoExecute
protected override void DoExecute(IElement element)
{
var name = element.GetAttr(HtmlAttribute.Name);
var supportsModelState = element as ISupportsModelState;
if(name == null || supportsModelState == null)
{
return;
}
ModelState state;
if (modelStateDictionaryFunc().TryGetValue(name, out state))
{
if(HasErrors(state))
{
element.Builder.AddCssClass(validationErrorCssClass);
}
if(state.Value != null)
{
supportsModelState.ApplyModelState(state);
}
}
}