无法从单个单元格单击触发Onclick事件 [英] Onclick event not firing from individual cell click
本文介绍了无法从单个单元格单击触发Onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在每次单击gridview中的单个单元格时触发一个onclick事件,但它没有调用该函数.我也尝试添加("onclick","Btn_AddNewSite_Click(sender,e)"),但该方法也不起作用.任何指向正确方向的指针都很好.
I am trying to fire an onclick event for whenever an individual cell in my gridview is clicked, but it is not calling the function. I also tried adding ("onclick", "Btn_AddNewSite_Click(sender, e)") and that did not work either. Any pointers in the right direction would be great.
e.Row.Cells[column].Attributes.Add("onclick", "Btn_AddNewSite_Click()");
protected void Btn_AddNewSite_Click(object sender, EventArgs e)
{
ModalPopupExtender1.PopupControlID = "Panel1";
ModalPopupExtender1.Show();
}
推荐答案
您可以通过确保Btn_AddNewSite
是LinkButton来实现.
You can do this by making sure that Btn_AddNewSite
is a LinkButton.
<asp:LinkButton ID="Btn_AddNewSite" runat="server" OnClick="Btn_AddNewSite_Click"></asp:LinkButton>
然后,您可以使用JavaScript代码来处理单元格中的LinkButton单击,方法是使用其唯一ID.
Then you can use the javascript code that handles the LinkButton click in the Cell by using it's UniqueID.
e.Row.Cells[column].Attributes.Add("onclick", "__doPostBack('" + Btn_AddNewSite.UniqueID + "', '')");
这篇关于无法从单个单元格单击触发Onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文