开发者

javascript for menu generation and displaying data in table

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜