Skip to content Skip to sidebar Skip to footer

Why Is Linkbutton Not Executing The Click Function From Code Behind

I have a GridView which has these two controls:

Solution 1:

If You Remove Both OnClientClick="return false;" and PostBackUrl="JavaScript:void(0);" then definitely it will postback. You can observe your HTML generated/rendered if you set both attributes with Postback event WebForm_DoPostBackWithOptions which should be something like

javascript:__doPostBack('BookingResults$ctl02$btnShow2','')

<ahref="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;BookingResults$ctl03$btnShow2&quot;, &quot;&quot;, false, &quot;&quot;, &quot;JavaScript:void(0);&quot;, false, true))"class="btnSearch2"id="BookingResults_btnShow2_1">View Alls</a>

Solution 2:

You have OnClientClick="return false;". That cancels the postback. To fix it, remove that attribute from your LinkButton declaration.

Also, not sure what PostBackUrl="JavaScript:void(0);" does. I've never seen someone to do that. You might try eliminating that if it's not necessary.

Post a Comment for "Why Is Linkbutton Not Executing The Click Function From Code Behind"