Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ClrImg();
        }
    }

    void ShowMIS()
    {
        lblName.Text = "MIS Department";
        deptImg.ImageUrl = "~/Images/MIS.jpg";
        deptImg.Visible = true;
    }
    void ShowFin()
    {
        lblName.Text = "Finance Department";
        deptImg.ImageUrl = "~/Images/Fin.jpg";
        deptImg.Visible = true;
    }
void ClrImg()
    {
        deptImg.Visible = false;
        lblName.Text = null;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ShowMIS();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        ShowFin();
    }
;
------------ the aspx file-----
ASP.NET
<td rowspan="2" style="width: 100px">
                        <asp:Image ID="deptImg" runat="server" Height="250px" Width="250px" BorderColor="#404040" BorderStyle="Double" BorderWidth="2px" /></td>
                    <td style="width: 400px">
                        <a href="#" id="MIS">MIS Department</a> <br />
                        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br />
                        <br />
                    </td>
                    <td style="width: 400px">
                        <a href="#" id="FIN">Finance Department</a>
                        <br />
                        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" /></td>
                

-------------------------------------------------

<a href="#" id="MIS"> MIS Department</a>


********************

i need help to call the ShowMIS() function when i move mouse over the link and call clrImage() function when i move mouse away
and so on if i move mouse on the other link like HR dept it should call ShowHR dept function and when mouse away should call clrImage() function

need some help with java script so that it can call code behind functions as stated above.

********************
Posted
Updated 13-Oct-15 0:50am
v3

1 solution

If you don't have strict in server side, it is better to do it in client side through javasript. Here is the code:

ASPX Code:
HTML
<a href="#" id="MIS" onmouseover="ShowMIS()" onmouseout="ClrImg()">MIS Department</a>

Javascript Code:
JavaScript
function ShowMIS()
{	
	document.getElementById("<%=deptImg.ClientID%>").style.display = "block";
	document.getElementById("<%=deptImg.ClientID%>").src = "/Images/MIS.jpg";
	document.getElementById("<%=lblName.ClientID%>").innerHTML = "MIS Department";
}

function ClrImg()
{	
	document.getElementById("<%=deptImg.ClientID%>").style.display = "none";
	document.getElementById("<%=lblName.ClientID%>").innerHTML = "";
}

Note: Just cross check the image path and set it as per your need.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900