ToolTimeGang
asked on
Manually built gridview is getting Invalid postback or callback argument when ImageButton is used.
I have a gridview in a vb (framework 4.0) web form.
I am filling it manually in the code behind.
I am not overriding the EnableEventValidation.
when I include this in the gridview:
<ItemTemplate>
<!-- Edit Button -->
<asp:ImageButton ID="imgEditDetail" runat="server"
ImageUrl="~/images/edit.gi f" ToolTip="Edit" CommandName="Edit" />
</ItemTemplate>
I get this when I click the edit button:
System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="tru e"/> in configuration or <%@ Page EnableEventValidation="tru e" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.Regist erForEvent Validation method in order to register the postback or callback data for validation.
However, when I use this, it works just fine. (Note...the issue noted at the bottom of this is the same thing I am getting:
http://msdn.microsoft.com/en-us/library/system.web.configuration.pagessection.enableeventvalidation(VS.90).aspx)
<ItemTemplate>
<!-- Edit Button -->
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit">Edit</a sp:LinkBut ton>
</ItemTemplate>
I understand the importance of keeping the EnableEventValidation=True . So I don't want to change that.
But how can I get this to work with my ImageButton?
On the same page, I added another gridview, only this one is filled using an objectdatasource (that is hooked up to our n-tier layers). When I throw an ImageButton on that gridview, it works just fine. I am thinking it doesn't work with the other because something is recognizing the fact that the data is getting changed between the posts, so it might be getting sql injected? so what is my work around please? My ImageButton is more pretty to look at than a plain ole link button.
Also, when I do set EnableEventValidation=Fals e, the error goes away, but then my gridview events don't seem to fire. (I have breakpoints set on my gridview events and when I click edit, I don't stop on the BP)
Thank you for helping me!
I am filling it manually in the code behind.
I am not overriding the EnableEventValidation.
when I include this in the gridview:
<ItemTemplate>
<!-- Edit Button -->
<asp:ImageButton ID="imgEditDetail" runat="server"
ImageUrl="~/images/edit.gi
</ItemTemplate>
I get this when I click the edit button:
System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="tru
However, when I use this, it works just fine. (Note...the issue noted at the bottom of this is the same thing I am getting:
http://msdn.microsoft.com/en-us/library/system.web.configuration.pagessection.enableeventvalidation(VS.90).aspx)
<ItemTemplate>
<!-- Edit Button -->
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit">Edit</a
</ItemTemplate>
I understand the importance of keeping the EnableEventValidation=True
But how can I get this to work with my ImageButton?
On the same page, I added another gridview, only this one is filled using an objectdatasource (that is hooked up to our n-tier layers). When I throw an ImageButton on that gridview, it works just fine. I am thinking it doesn't work with the other because something is recognizing the fact that the data is getting changed between the posts, so it might be getting sql injected? so what is my work around please? My ImageButton is more pretty to look at than a plain ole link button.
Also, when I do set EnableEventValidation=Fals
Thank you for helping me!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yeah, I saw that I forgot the closing tag on the image control... I assumed you could figure it out ;)
Glad it got working... sometimes, you just gotta step back and see describe what you are trying to do, and other solutions seem to appear magically. Do you need anything else?
Glad it got working... sometimes, you just gotta step back and see describe what you are trying to do, and other solutions seem to appear magically. Do you need anything else?
ASKER
Nope...I'm good! Thanks again!
ASKER
There was a slight syntax error with your line...so I used this:
<asp:LinkButton ID="LinkButtonEdit" runat="server" CausesValidation="false" CommandName="Edit">
<asp:Image ID="imgFolder" runat="server" ImageUrl="~/images/edit.gi
</asp:LinkButton>
Issue resoloved. Also, when I have BPs set in the GridView events, the code does fire with this. So I'm all good now!
Thank you onyx!