禁用的asp控件不会将标题呈现为标题

时间:2022-11-04 16:12:19

I am trying to use jquery tooltip on an asp:Textbox. The problem is that I can't manage to make the title tag render as a title. It keeps rendering as data-original-title. I am using twitter bootstrap which I think can be a reason to this behaviour.

我试图在asp:Textbox上使用jquery工具提示。问题是我无法将标题标记呈现为标题。它一直呈现为数据原始标题。我正在使用twitter bootstrap,我认为这可能是这种行为的原因。

I have tried adding "title" and "tooltip" to my textbox, I have tried adding textbox attribute "title" from code behind but nothing changed. This is how it looks when rendered (I have omitted all unnecessary code):

我试过在我的文本框中添加“标题”和“工具提示”,我尝试从代码后面添加文本框属性“标题”,但没有任何改变。这是渲染时的外观(我省略了所有不必要的代码):

<input type="text" title data-original-title="My Text">

As you see, title is rendered, but with no data, and my actual text is placed in a new unwanted attribute. Below is what I want to accomplish for the jquery tooltip to work.

如您所见,标题已呈现,但没有数据,我的实际文本被放置在新的不需要的属性中。以下是我想要使jquery工具提示工作的目标。

<input type="text" title="My Text">

I have to use an asp control, otherwise this wouldn't be an issue.
Any suggestions?

我必须使用asp控件,否则这不会是一个问题。有什么建议么?

EDIT
I did not mention that the control is disabled, because I thought it wouldn't make any difference. But in fact I just realised it works fine on an enabled asp control.
Problem still remains though because it's only when the control is disabled that i need the tooltip.

编辑我没有提到控件被禁用,因为我认为它没有任何区别。但实际上我刚刚意识到它在启用的asp控件上工作正常。问题仍然存在,因为只有在禁用控件时才需要工具提示。

2 个解决方案

#1


1  

You can use Attributes to set title

您可以使用属性来设置标题

txtBox1.Attributes.Add("title", "My Text");

OR

要么

txtBox1.Attributes["title"] = "My Text";

#2


0  

Well this is not tested but i have an idea

嗯,这没有测试,但我有一个想法

<input type="text" data-getmytitle="your title">
//This is your element
function getmebinded()
{
$('input["data-getmytitle="your title""]').each(function()
{
    $(this)[0].title="your title";
});
}
//make your function that will bind title to your element
$(document).ready(function()
{
  var aa=getmebinded();
 });
// so now this will call your function of javascript after page has been loaded and your js also 

this should be work tell me feedback about this i hope this one will help you the simple logic is bind title after page and your js has been loaded...regards...:)

这应该是工作告诉我关于这个的反馈我希望这个将帮助你简单的逻辑是绑定标题后页和你的js已经加载...问候... :)

#1


1  

You can use Attributes to set title

您可以使用属性来设置标题

txtBox1.Attributes.Add("title", "My Text");

OR

要么

txtBox1.Attributes["title"] = "My Text";

#2


0  

Well this is not tested but i have an idea

嗯,这没有测试,但我有一个想法

<input type="text" data-getmytitle="your title">
//This is your element
function getmebinded()
{
$('input["data-getmytitle="your title""]').each(function()
{
    $(this)[0].title="your title";
});
}
//make your function that will bind title to your element
$(document).ready(function()
{
  var aa=getmebinded();
 });
// so now this will call your function of javascript after page has been loaded and your js also 

this should be work tell me feedback about this i hope this one will help you the simple logic is bind title after page and your js has been loaded...regards...:)

这应该是工作告诉我关于这个的反馈我希望这个将帮助你简单的逻辑是绑定标题后页和你的js已经加载...问候... :)