Consider the following:
protected void dgTask_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton btn = (LinkButton)e.Row.Cells[4].FindControl("lnkBtnEdit");
btn.Attributes.Add("onclick", "return Test();");
}
}
Instead of a single click, how can I make it double click while clicking on the link button?
Edited
I have tried with the solution presented by *competent_tech* but the problem is that in that case it will intercept the single click.
I need to do some operation on single click and something else on double click. Please help me.
Thanks
You’d have to do something like this.
Code behind.
then in your javascript you’ll need to define the OnClick function like this
You can either put the javascript directly into your .aspx file or add it dynamically when you add the LinkButton to the page. If you need to perform some action on the server side when the user single clicks or double clicks you can use the __doPostBack method. See here for more info on that.
The problem with my approach is that the user will always have to wait the entire callback time before their single click action is performed. I don’t see any way around this as long as you are using single click/double click to distinguish what the user wants. If you find this delay to be too big of a problem you could always try something like click/shift+click to alternate between the actions. It probably wouldn’t be as intuitive that way but you would immediately know what the user wants and could respond immediately instead of waiting to see if the user clicks a second time.
Let me know if you have any questions.