ASP.NET - how to show image with its description on mouseover event

Asked By pradnya on 08-Jun-10 03:41 AM
how to show image with its description on mouseover event plz tell me.
Suraj V replied to pradnya on 08-Jun-10 04:28 AM
Hi,

To show image with description on mouseover event .

There are 2 approaches for this

(1) Set the title attribute of image control with description to show on mouseover event in markup code.
    Eg. <img id="i1" src =""  title="some description">

(2) To set description in code behind file
    <asp:ImageButton ID="i1" runat="server" ToolTip = "Some description" />

    Set the ToolTip property to show description on mouseover event on image button.
pradnya replied to Suraj V on 08-Jun-10 05:33 AM
 i want to show the description in the texbox or label not in the tooltip
pradnya replied to Suraj V on 08-Jun-10 05:34 AM
 i want to show the description in the texbox or label not in the tooltip
pradnya replied to Suraj V on 08-Jun-10 05:34 AM
 i want to show the description in the texbox or label not in the tooltip
Suraj V replied to pradnya on 10-Jun-10 06:14 AM
If you want to display description in textbox on mouseover event on image button, then in that case you can hold the description in a hidden field.

<asp:HiddenField Id="hdnDesc" Value="Description goes here" />

Create a javascript method to show description on image button mouseover event.

<script language='javascript'>
 
function ShowImageDescription()
{
    // get the textbox control in which description will be shown.
    var textbox =  document.getElementbyId(textbox_control_id);
    var description  =  document.getElementbyId(hiddenfield_control_id).value;
    
    if(description  !=undefined)
    {
        textbox.value = description  ;
    } 
    
}

</script>

call this javascript method on image button mouseover event.

<asp:ImageButton ID="imgButton" runat="server" onmouseover = "javascript:ShowImageDescription();" / >


This is how you can show description in a textbox whenever you move mouse over image.

----