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

[Solved] fast multiple clicks on insert button

1 Answer 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Sornea
Top achievements
Rank 1
John Sornea asked on 08 Feb 2010, 09:44 AM
When I click fast a few times on the insert button in edit mode on a grid, a got the same data entered multiple times.
How can I disable this behaviour? I mean If i click multiple times on insert, the data should be inserted only one time.
After the first click on the insert button, this button should be disabled. I am using RadAjaxManager.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Feb 2010, 11:40 AM
Hello John,

Try the following approach in order to disable the button after first click.

CS:
 
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    {    
        if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridDataInsertItem) 
        { 
            GridDataInsertItem item = (GridDataInsertItem)e.Item; 
            LinkButton linkButton = (LinkButton)item.FindControl("PerformInsertButton"); 
            linkButton.Attributes.Add("onclick","disableIt(this);"); 
        }       
    } 

JavaScript:
 
<script type="text/javascript"
    var check = false
    function disableIt(lnkbtn) { 
        if (!check) { 
 
            lnkbtn.disabled = true
        } 
        else { 
            return false
        } 
    } 
</script> 

-Shinu.
Tags
Grid
Asked by
John Sornea
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or