Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I have a gridview with image buttons but when I click on these button it is not working (not responding).

Gridview Code:

This gridview is under updatepanel.

XML
<asp:TemplateField ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center">
                                                                               <ItemTemplate>                                                                                  <asp:ImageButton ID="imgbtnUndo2" CommandName="Revert" runat="server" ToolTip="Undo"                                                                                                                                                       ImageUrl="~/Images/Undo.png" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' />                                                                               </ItemTemplate>                                                                         </asp:TemplateField>



Can any one help me on this.

Thanks in advance...
Posted
Updated 20-Jun-13 2:22am
v2
Comments
Mahesh Bailwal 20-Jun-13 6:11am    
Are you getting some JavaScript error. Also please make sure you have "display notification about every script error" on IE 10 is turned on.
NaVeN Kumar 20-Jun-13 8:21am    
Hello Mahesh,

No script error is giving... but this code is in updatepanel... I removed updatepanel and tried then it worked fine... What I need to do now...?

1 solution

I think you're missing the OnCommand event capture because you have command name and command arguments but no event. Try something like this.
ASP.NET
<asp:TemplateField ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center">                                                                               <ItemTemplate> 
                                                                                 <asp:ImageButton ID="imgbtnUndo2" OnCommand="imgbtnUndo2_OnCommand" CommandName="Revert" runat="server" ToolTip="Undo"                                                                                                                                                       ImageUrl="~/Images/Undo.png" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' />   
                                                                            
</ItemTemplate>                                                                       </asp:TemplateField>


You will need to handle the OnCommand event in codebehind for the image button to do anything, the handler should be named "imbtnUndo2_OnCommand" in this case.

PS: Code project removed all my capitals somehow, but hope this solves it.
 
Share this answer
 
v3
Comments
NaVeN Kumar 22-Jun-13 0:42am    
Hello Silvabolt,

I have used onRowCommand event for this... This code is working in IE9 but not in IE10. It is firing if I remove update panel.. I used trigger also... I don't know why it is not working in IE10...

<Triggers>
<asp:AsyncPostBackTrigger ControlID="grdCustomerUsers" EventName="RowCommand" />
</Triggers>
Silvabolt 23-Jun-13 12:00pm    
Hi Naven Kumar,

It seems the problem is not your code, but Microsoft IE 10 itself. The postback operation fails in IE 10 when you have an image button inside a update panel. You need to update your .NET 4.0 framework with this patch (refer to Issue 2):

http://support.microsoft.com/kb/2836939

Source link:
https://connect.microsoft.com/VisualStudio/feedback/details/755419/asp-net-4-0-and-ie10-click-on-imagebutton-in-updatepanel-produces-error-click-on-normal-button-does-not
NaVeN Kumar 24-Jun-13 2:07am    
Hello Silvabolt,

Thanks for your valuable information.... :)

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