I am generating a menu using an unordered list (ul) and I want to display some specific data on a mouseover event of each li. I also want to add data to a gridview. The data to be displayed is related to the va开发者_如何转开发lue in li and is to be fetched from a SQL database.
I was wondering if anybody could give me any suggestions as to how I might go about doing this?
P.S. I am using C# on the server side.
You can use add onmouseover attribute while generating your LI nodes.
<li onmouseover='yourjavascriptcode'></li>
You can find example here. Adding attributes to server side controls is explained here.
I think the best solution is to use jQuery to match your elements, and attach mouseover event:
$('#yourUlID li').mouseover(
function() {
//your js code
}
);
Example here.
If you want to add data fetched from database to the html table I do not recommend using gridview. Just use Ajax and put fetched data into simple and light html table. If you don't know how to use Ajax with jQuery this article should be helpful for you.
精彩评论