Javascript 如何在ASP.NET C#中单击客户端时检测控件?

Javascript 如何在ASP.NET C#中单击客户端时检测控件?,javascript,c#,asp.net,Javascript,C#,Asp.net,我有一个带有OnClientClick事件的图像按钮来加载Ajax 我想检测是否单击了我的图像按钮。我会努力的,但是运气不好 这是我的代码: ImageButton imgbtn = new ImageButton(); imgbtn.Height = 25; imgbtn.CssClass = "light"; imgbtn.ID = "led" + i; imgbtn.OnClientClick = "Turnon('" + table.Rows[i]["Url"].ToString(

我有一个带有OnClientClick事件的图像按钮来加载Ajax

我想检测是否单击了我的图像按钮。我会努力的,但是运气不好

这是我的代码:

ImageButton imgbtn = new ImageButton();   
imgbtn.Height = 25;
imgbtn.CssClass = "light";
imgbtn.ID = "led" + i;
imgbtn.OnClientClick = "Turnon('" + table.Rows[i]["Url"].ToString() + "');";
//If i can detected that my imgbtn is clicked
//I will do something
对不起,如果我的问题不清楚,我会尽力告诉你我的想法。 谢谢

这是解决方案

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script>
        function Turnon(url)
        {
            alert(url);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    </form>
</body>
</html>

嗨,我试过了,它起作用了。创建控件后,需要将其添加到
表单
,并在aspx中创建新的javascript函数
函数开启(url){}
ImageButton imgbtn = new ImageButton();
imgbtn.Height = 25;
imgbtn.CssClass = "light";
imgbtn.ID = "led";
imgbtn.OnClientClick = "Turnon('" + "www.google.com" + "');";

form1.Controls.Add(imgbtn); //