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

Issue with Insert linkbutton in User Control edit form when clicked repeatedly

2 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sandra Walters
Top achievements
Rank 1
Sandra Walters asked on 29 Apr 2010, 09:10 PM
Hello all!

I am using a RadGrid with a custom User Control as both the insert and edit form.  Within the User Control, I've defined two linkbuttons (for insert/update and for cancel) as follows:

            <asp:LinkButton ID="lkbUpdate" ValidationGroup="LocDetail"  
                Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' 
                runat="server" OnClientClick="Insert_Click();" 
                CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
            </asp:LinkButton>&nbsp; 
            <asp:LinkButton ID="lkbCancel" Text="Cancel" runat="server" CausesValidation="False" 
                CommandName="Cancel"
            </asp:LinkButton> 
 

The actual insert (or update) logic is performed in the grid's OnInsertCommand and OnUpdateCommand handlers.  In this particular scenario, when the user performs the insert action, a number of things are going on behind the scenes (including some calculations that take a couple of seconds to complete).  During this time, the User Control form stays visible to the user.  I've added a Javascript function to the click event on the linkbutton in which I am displaying an hourglass cursor while the progress completes.

The problem I'm experiencing is that the users are impatient, and are ignoring the wait cursor and repeatedly clicking on the Insert/Update link button while the popup is visible. This is resulting in multiple, identical rows being added to the grid.  Indeed, you can see this behavior in the Telerik example of a User Control edit form at this page here - enter new data in the edit form and click on the Insert button repeatedly.  The row will be entered multiple times.

I haven't found a way to effectively disable the link button upon the click event without breaking other RadGrid behavior.  For example, within the Javascript click() handler, I've tried both disabling the button as well as clearing the href attribute; both actions prevent the RadGrid from successfully closing the popup once the insert is done.

Has anyone encountered this issue and, if so, have a workaround?


2 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 04 May 2010, 04:02 PM
Hello Sandra,

You can totally hide the link button once it is pressed. Simply use the OnClientClick event handler:

<asp:LinkButton ID="lkbUpdate" ValidationGroup="LocDetail" 
    OnClientClick="this.style.display = 'none'"
    Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
    runat="server" OnClientClick="Insert_Click();"
    CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</asp:LinkButton>


Regards,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sandra Walters
Top achievements
Rank 1
answered on 04 May 2010, 05:10 PM
Thanks for the reply Veli, that worked!
Tags
Grid
Asked by
Sandra Walters
Top achievements
Rank 1
Answers by
Veli
Telerik team
Sandra Walters
Top achievements
Rank 1
Share this question
or