在asp.net TreeView控件的替代文本 [英] Alternative Text in treeview control in asp.net

查看:89
本文介绍了在asp.net TreeView控件的替代文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个解决方案。我的TreeView控件包含了我的web应用程序中的菜单项,并从一个网站地图,它的人口和它的正常工作。现在我需要替代文本添加到创建的菜单项。我如何替换文本添加到这些树视图项目。

我的树状code是像下面

 保护无效MainMenu_NodeDataBound(对象发件人,TreeNodeEventArgs E)
{
    VAR的SiteMapNode = e.Node.DataItem为的SiteMapNode;
    e.Node.Value = siteMapnode.Url;
    e.Node.NavigateUrl =的String.Empty;
    e.Node.SelectAction =(siteMapnode.Url!=的String.Empty)? TreeNodeSelectAction.Select:TreeNodeSelectAction.None;
    e.Node.PopulateOnDemand = FALSE;
}


解决方案

有没有 ALT 。我相信你想要的是标题,它是使用工具提示属性设置:

  e.Node.ToolTip =我提供有关的链接有用的信息。

这将让呈现为:

 < A HREF =yourlink.aspx称号=我提供有关的链接有用的信息。>有的文字< / A>

ALT 用于为元素指定替代文本时,它们不能被渲染(即非锚标记)。 IE浏览器之外,浏览器将的的使用提供当元素悬停显示文本。

HTML技术的Web内容辅助功能准则1.0 :


  

除了清晰的链接文字,内容开发者可以指定一个值
  标题属性清楚,准确地描述了
  链接的目标。


  
  

如果一个页面上的多个链接共享相同的链接文字,所有这些
  链接应指向相同的资源。这种一致性将有助于
  页面设计以及可访问性。


  
  

如果两个或更多的链接指向不同的目标,但共享相同的
  链接文本,通过指定不同的值区分链接
  标题每一个元素的属性。


I am looking for a solution. My treeview control contains the menuitems for my web application and its populated from a sitemap and it's working fine. Now I need to add alternative text to that menu items created. How can I add alternative text to these treeview items.

My treeview code is like below

protected void MainMenu_NodeDataBound(object sender, TreeNodeEventArgs e)
{
    var siteMapnode = e.Node.DataItem as SiteMapNode;
    e.Node.Value = siteMapnode.Url;
    e.Node.NavigateUrl = string.Empty;
    e.Node.SelectAction = (siteMapnode.Url != String.Empty) ? TreeNodeSelectAction.Select : TreeNodeSelectAction.None;
    e.Node.PopulateOnDemand = false;         
}

解决方案

There is no alt. I believe what you want is title, which is set using the ToolTip attribute:

e.Node.ToolTip = "I provide useful info about the link."

Which will get rendered as:

<a href="yourlink.aspx" title="I provide useful info about the link.">Some Text</a>

alt is used to specify alternate text for elements when they can't be rendered (i.e. NOT anchor tags). Outside of IE, browsers will not use this to provide text that displays when the element is hovered.

From HTML Techniques for Web Content Accessibility Guidelines 1.0:

In addition to clear link text, content developers may specify a value of the "title" attribute that clearly and accurately describes the target of the link.

If more than one link on a page shares the same link text, all those links should point to the same resource. Such consistency will help page design as well as accessibility.

If two or more links refer to different targets but share the same link text, distinguish the links by specifying a different value for the "title" attribute of each A element.

这篇关于在asp.net TreeView控件的替代文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆