This is a migrated thread and some comments may be shown as answers.

PerformInsert __EVENTTARGET

2 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lasly
Top achievements
Rank 1
Lasly asked on 15 Sep 2011, 02:42 PM
Hi,
I need to intercept the __EVENTTARGET during the PageLoad when I rise the PerformInsert action into RadGrid.
If I use ButtonType =  Image my Request["__EVENTTARGET"] is blank, if I use ButtonType = LinkButton my Request["__EVENTTARGET"] has the correct value.

I don't wanna use LinkButton, so, why my button with ImageButton don't have the tipically __doPostBack("...........$PerformInsertButton", ''); and why I can find it into my Reques["__EVENTTARGET"] ?

Thanks

Best regards

2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 21 Sep 2011, 09:33 AM
Hi Lasly,

The described issue is not related with the RadGrid. The same behavior could be observed with standard asp:ImageButton and asp:LinkButton placed on the page. For example:
<asp:LinkButton runat="server" ID="LinkButton1" Text="Postback"></asp:LinkButton>
<asp:ImageButton runat="server" ID="ImageButton1" />
protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
 
        var eventTarget = Request["__EVENTTARGET"];
    }

When the LinkButton1 is clicked the eventTarget will contain the unique name of the LinkButton1, however when the ImageButton1 is clicked the eventTarget will be empty string.

To detect which image button caused the postback you could check the following forum post which elaborate on this matter:
http://bytes.com/topic/asp-net/answers/322401-detect-imagebutton-caused-postback

Additionally you could handle the RadGrid.ItemCommand and check it the e.CommandName == RadGrid.PerformInsertCommandName:
void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.PerformInsertCommandName)
        {
        }
    }

Please give it try and let me know if it helps you.

Best wishes,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Lasly
Top achievements
Rank 1
answered on 21 Sep 2011, 01:47 PM
Thanks for the reply,
I've read the link and it works!

Best Regards
Tags
Grid
Asked by
Lasly
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Lasly
Top achievements
Rank 1
Share this question
or