0

I have a label on my asp.net page, it looks like this:

more info

When I hover over it, I'd like one of those jquery tooltips to display. The data will come from a database from my code behind. I've look at qtip, jquery tools, and the telerik tooltip. I'm just not sure how to set the content of the tooltip from server side.

2 Answers 2

1

The simplest implementation using tooltip plugin (http://docs.jquery.com/Plugins/Tooltip) will be just:

$("a").tooltip();

The above use title as the default tooltip content.

Suppose you have X items to be tooltipped with X custom content in a sequence, here's one way

In your code-behind, string up the tooltips like this:

protected string tooltips;
//perform your data retrieval and create a string like this:
tooltips = "'tip1','tip2','tip3'";

In your javascript, to assign the tooltip string array to a javascript array:

var myToolTips = new Array(<%=mytooltips%>);

Then iterate through the items using JQuery's each():

$(".someclass a").each(function(i){
    $(this).tooltip({
       showBody: myToolTips[i];
    });
})
Sign up to request clarification or add additional context in comments.

Comments

1

I usually set a literal control to print out the value from the server I want the jQuery code to have.

So something like this:

$("div").html("<asp:literal id='litServerData" runat="server"></asp:literal>");

Then in your codebehind you set the literal to the data you want your jQuery code to have.

Of course this only works if your jQuery is on the aspx page. If not you can have a script block at the top of the page that sets a variable to the literal control value and then call your external script.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.