开发者

ToolTip text as selected value in ASP.Net dropdown

开发者 https://www.devze.com 2023-01-10 23:43 出处:网络
I have ASP.NET dropdown which is too small to display full text the user had selected. So i decided to display selected text in tooltip.

I have ASP.NET dropdown which is too small to display full text the user had selected. So i decided to display selected text in tooltip.

ApplyToDropDown.Attributes.Add("onMouseOver", "ShowApplyToText()");

function ShowApplyToText()
{
    var ApplyToDropDown = document.getElementById("ApplyToDropDown"); 
  开发者_运维百科  if(ApplyToDropDown != null)
          ApplyToDropDown.ToolTip = ApplyToDropDown.selectedText; // line 5
}

But i am not getting an output.I also tried ApplyToDropDown.title it also didn't work.

Please help me on this.


ToolTip is not a valid attribute of a dropdown element (or its option elements) so unfortunately your script won't work. The attribute you want to use is title, but unfortunately that will only work on the top dropdown element and not on each option element as you are looking for.

The only way to get this to work would be with some javascript/css trickery where you would hover a div with the tooltip in it next to the dropdown, but there's nothing unfortunately that's built-in that can do this.


If you add the title attribute, then it will work in browsers other than IE.

The drop down list renders as a select element in HTML, which is why it doesn't typically have a tooltip.

Have a read of this forum topic.

0

精彩评论

暂无评论...
验证码 换一张
取 消