Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a linkbutton inside a gridview. when I click on it onclientclick has some validation if we get true onclick has to perform else not perform. But here onclick is not firing.

What I have tried:

Aspx page:
<asp:TemplateColumn HeaderText="Assign Source Locations" HeaderStyle-CssClass="ReportDataHeader">
<asp:LinkButton CssClass="SearchLabel" ID="lnkbtnAssignLoc" runat="server" Text="Assign Locations" UseSubmitBehavior="false" CausesValidation="false" OnClientClick="return ToggleEnable(this);">


function ToggleEnable(src) {
var row = src.parentNode.parentNode;
var rowIndex = row.rowIndex - 1;
var element = row.cells[3].getElementsByTagName("select");
var ddlSelectedValue = element[0].options[element[0].selectedIndex].text;
var SourceLocations = row.cells[4].innerHTML;

if (ddlSelectedValue == "Par Locations") {
return true;
else {
document.getElementById("lnkbtnAssignLoc").disabled = true;
return false;

Code behind:

lnkbtnLoc.Attributes.Add("OnClick", _
"return showDocumentPopup('mt_pou_assign_process_locations.aspx?qStrOrgGrpID=" & _deviceTokenEntry(TokenEntry_Enum.OrgGrpID) & "&qstrLocGrpId=" & e.Item.Cells(2).Text & "&qstrOrgID=" & ddlOrgId.SelectedValue & "&qstrSourceLocations=" & e.Item.Cells(5).Text & "');")

Above OnClick is not firing.
Please suggest me how to proceed
Updated 15-Jul-16 4:11am

1 solution

The LinkButton adds some extra Javascript to the end of the client-side click event to trigger a post-back. Your code always returns before that code can be triggered.

Change your OnClientClick code to:
OnClientClick="if(!ToggleEnable(this))return false;"
Share this answer
VinodKumar_Dev 19-Jul-16 10:03am    
Thank You Richard..!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900