Gridview has buttons for each row like delete/edit button. Those buttons are binded with client side methods (onClick), no more server side methods.
Problem is, when I click first time, button is not firing the client side method, But when I click second time its working..
This is not acutally brower issue. Because, I have checked with all browers. Not working.
Codes: I have binded this attribute under gridview xx_RowDataBound method.
ibCancel.Attributes["OnClick"] = "javascript: return CancelAdminExtension('" + hidRemarks.ClientID + "','" + bPastExtension + "','" + hidDelRecNr.ClientID + "','" + hidRecNr.Value + "','" + hidDelPurpose.ClientID + "','" + hidPurpose.Value + "');";
Javascript method:
function CancelAdminExtension(strPurposeID, strPastExtension, strDelRecNr, strRecNr, strDelPurpose, strPurpose) {
try
{
//some logic here
hidDelRecNr.value = strRecNr;
hidDelPurpose.value = strPurpose;
return true;
}
catch(err)
{
return false;
}
}
Please suggest any idea to solve this issue.
Sorry, this question may duplicate other questions, I couldn't find the solution to solve my issue.
protected void uxCustomGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton uxEditLinkButton = (LinkButton)e.Row.FindControl("uxEditLinkButton");
uxEditLinkButton.Attributes["onclick"] = string.Format("return doEdit({0})", item.ID);
}
}
Does the first click have some reactions? Usually, I use the code below to bind client events on the back end.
Or you can just test onclick event use a easy alert function.
try using once Attributes.Add("onclick", "script")
instead of Attributes["OnClick"]
ibCancel.Attributes.Add("onclick", "return(CancelAdminExtension('" + hidRemarks.ClientID + "','" + bPastExtension + "','" + hidDelRecNr.ClientID + "','" + hidRecNr.Value + "','" + hidDelPurpose.ClientID + "','" + hidPurpose.Value + "'));");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.