Kentico 表格咏叹调标签

Kentico Form Aria-Label

是否可以将 aria 标签添加到 Kentico 表单中。我正在使用在线表单小部件将表单添加到我的页面,我想为每个部分添加 aria 标签,以帮助使我的网站更符合 ADA 标准。

我在 Kentico 中没有看到默认选项。不过这是一个很好的要求。您需要做的是创建您自己的具有 属性.

的表单控件

https://docs.kentico.com/k10/custom-development/developing-form-controls

您要做的是克隆文本框,将名为 "AriaLabel" 的 属性 添加到表单控件的属性中,然后将其添加到文本框的新代码文件中

在属性区域中:

public string AriaLabel
{
    get
    {
        return ValidationHelper.GetString(GetValue("AriaLabel"), "");
    }
    set
    {
        if (txtValue.Attributes["AriaLabel"] != null)
        {
            txtValue.Attributes["AriaLabel"] = ValidationHelper.GetString(GetValue("AriaLabel"), "");
        }
        else
        {
            txtValue.Attributes.Add("AriaLabel", ValidationHelper.GetString(GetValue("AriaLabel"), ""));
        }
    }
}

在底部的 Page_Load 中:

if (txtValue.Attributes["AriaLabel"] != null)
            {
                txtValue.Attributes["AriaLabel"] = AriaLabel;
            }
            else
            {
                txtValue.Attributes.Add("AriaLabel", AriaLabel);
            }

如果您要为字段使用 label 属性,它将在 HTML 布局中为其生成 label 标记,这将符合可访问性。这会解决您的目的,还是您只是专门寻找 aria-label 标签?