如何在gridview boundfield单元格的onpaste事件上调用javascript函数 [英] How to call javascript function on onpaste event for gridview boundfield cells

查看:55
本文介绍了如何在gridview boundfield单元格的onpaste事件上调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨......



我正在尝试将onPaste事件绑定到gridview每个单元格。我在使用gridview的绑定字段。我可以调用javascript函数关于每个单元格的onpaste事件。提供一个soln。

thanx

hi...

I am trying to bind onPaste event to gridview each cell.Here i am using bound fields for gridview.how i can call javascript function on onpaste event of each cell.provide a soln.
thanx

推荐答案

Hello Vijay,



在Gridview行创建的事件中,获取单元格的控件并向该控件添加属性,如下所示:



Hello Vijay,

On Gridview row created event, get the control of the cell and add attribute to that control as follows:

void grd_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if ((e.Row.RowType == DataControlRowType.DataRow))
        {
            if (e.Row.Cells[0].Controls.Count > 0 && grd.EditIndex != -1)
            {
                try
                {
                    TextBox tbTxt = (TextBox)e.Row.Cells[0].Controls[0];
					if(tbTxt != null)
					{
						tbTxt.Attributes.Add("onpaste", "return yourJSfunction()");
					}
				}
			}
		}
	}


这篇关于如何在gridview boundfield单元格的onpaste事件上调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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