需要有关此Java脚本的帮助,以调用函数背后的代码 [英] Need help with this java script to call code behind function

查看:140
本文介绍了需要有关此Java脚本的帮助,以调用函数背后的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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();
    }

;
------------ aspx文件-----

;
------------ the aspx file-----

<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>



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

当我将鼠标移到链接上时需要帮助来调用ShowMIS()函数,而当我将鼠标移开时要调用clrImage()函数
依此类推,如果我将鼠标移到其他链接(例如HR dept)上,则应调用ShowHR dept函数,当鼠标移开时应调用clrImage()函数

需要有关Java脚本的一些帮助,以便它可以在如上所述的函数后面调用代码.

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



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

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.

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

推荐答案

如果您对服务器端没有严格要求,最好通过javasript在客户端执行此操作.这是代码:

ASPX代码:
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:
<a href="#" id="MIS" onmouseover="ShowMIS()" onmouseout="ClrImg()">MIS Department</a>


JavaScript代码:


Javascript Code:

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.


这篇关于需要有关此Java脚本的帮助,以调用函数背后的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆