如何访问onClick事件处理程序 [英] How to access the onClick event handler

查看:84
本文介绍了如何访问onClick事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有GridView的表单.在GridView的RowDataBound事件中,按如下方式添加onClick事件:

I have a form with a GridView on it. In the GridView''s RowDataBound event I add the onClick event as follow:

e.Row.Attributes.Add("onclick", "divexpandcollapse('" + WorkItemID.Value + "','" + txnID.Value + "')");



我将Javascript方法称为"divexpandcollapse",该方法带有一些参数.

如何访问文件背后代码中的onClick事件,例如,如果某行发生行单击,则需要执行javascript函数以及文件背后代码中的某些方法.

任何帮助将不胜感激.



I call the the Javascript method "divexpandcollapse" which takes some parameters.

How can I access the onClick event in my code behind file, for example, if the row click happens for a certain row, I need the javascript function to be executed and some method in my code behind file.

Any help would be greatly appreciated.

推荐答案

在单击时更改GridView行颜色而无需回发 [ ^ ]

http://stackoverflow.com/questions/6366827/how-to-attach-javascript-on-click-event-of-gridviews-editbutton-deletebutton [
http://stackoverflow.com/questions/9808460/executing-javascript-on-selecting-gridview-row-then-executing-a-database-query-b

Change the GridView row color on click without postback[^]

http://stackoverflow.com/questions/6366827/how-to-attach-javascript-on-click-event-of-gridviews-editbutton-deletebutton[^]


javascript:
javascript :
function divexpandcollapse()
    {
        var bntEvent = document.getElementById("<%= Button2.ClientID %>");
        bntEvent.click();
    }


这篇关于如何访问onClick事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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