从代码隐藏向超链接控件添加替代文本
Add alternate text to hyperlink control from codebehind
我正在根据网络服务的反馈根据需要从代码隐藏文件创建可点击的图像。我使用 hyperlink() 方法创建超链接
HyperLink hyplAlertbox = new HyperLink();
然后使用 "imageUrl" 属性
添加图像
hyplAlertbox.ImageUrl = "~/templateimages/alert_scale_1.jpg";
这可行,但图像不包含替代文本,这是一个可访问性问题。有没有办法从后面的代码中添加替代文本,或者我需要求助于 javascript?
谢谢
要为 HyperLink
控件设置替代文本,您可以使用以下命令:
HyperLink hyplAlertbox = new HyperLink();
hyplAlertbox.ImageUrl = "~/templateimages/alert_scale_1.jpg";
hyplAlertbox.Text = "Your alt text";
请确保您的 .Text
在您设置 ImageUrl
.
之后 出现
我正在根据网络服务的反馈根据需要从代码隐藏文件创建可点击的图像。我使用 hyperlink() 方法创建超链接
HyperLink hyplAlertbox = new HyperLink();
然后使用 "imageUrl" 属性
添加图像hyplAlertbox.ImageUrl = "~/templateimages/alert_scale_1.jpg";
这可行,但图像不包含替代文本,这是一个可访问性问题。有没有办法从后面的代码中添加替代文本,或者我需要求助于 javascript?
谢谢
要为 HyperLink
控件设置替代文本,您可以使用以下命令:
HyperLink hyplAlertbox = new HyperLink();
hyplAlertbox.ImageUrl = "~/templateimages/alert_scale_1.jpg";
hyplAlertbox.Text = "Your alt text";
请确保您的 .Text
在您设置 ImageUrl
.