开发者

Mouse Rollover event for ASP.NET control

I have a ASP.NET ImageButton control (no AJAX) with a Image_Click event that fetches data from SQL server. Now I want to add a Mouse Rollover to the Image Button that should fetch the data from the SQL server and display it on a Label.

I know you can add a Javascript Mouse Rollover event on the Image Button. imgae_Button.Attributes.Add("onmouseover", "myJacascriptFunction()");

How do I get the Javascript code fire Server side code t开发者_StackOverflow中文版o fetch the SQL data? Can this be done?

EDIT: Clarification onclick() event not only fetches data from SQL but also writes to another table. This event has alreday been coded without AJAX. It is the mouse rollover event that I need help with. When the user hovers over the image, data should be fetched from SQL database & displayed on a label control.


This sure can be done, and will almost certainly involve AJAX.

In your mouse rollover event you want to define myJavascriptFunction() to click the image button on the users behalf, this will subsequently postback to the server as if the user had simply clicked.

You then want to place the image button and the label you want to show the answer into an UpdatePanel and ensure you stick a ScriptManager on the page too to handle the request/response.

This should achieve what you want.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜