Delete LinkButton firing when Enabled = False

3 posts, 1 answers
  1. Kellie
    Kellie avatar
    29 posts
    Member since:
    Feb 2009

    Posted 05 Jan 2011 Link to this post

    Im in version 2010.3.1215.35 using IE 8.

    Even though I have disabled my Delete LinkButton in the ItemDataBound event, and it looks disabled, I am still able to click it, which prompts me with the delete comfirmation message. When I click to confirm, it deletes my record.

    Here's my code behind where I disable the LinkButton

    protected void RadGridWorkRequestAsset_ItemDataBound(object sender, GridItemEventArgs e)
    {
                //Other code here
      
                if (e.Item is GridDataItem)
                {
                    var editItem = ((GridDataItem)e.Item);
                    var deleteButton = (LinkButton)editItem["DeleteColumn"].Controls[0];
      
                    if (deleteButton != null)
                    {
                        deleteButton.Enabled = false;
                    }                 
                 }
      
                //Other code here
    }


    Here's my LinkButton on the ASCX page:
    <telerik:GridClientDeleteColumn ConfirmText="Delete this record?" ButtonType="LinkButton"  UniqueName="DeleteColumn" ConfirmTitle="Delete" ConfirmDialogType="Classic" CommandName="Delete">
    </telerik:GridClientDeleteColumn>

    I will also create a ticket so I can send you a small sample project to duplicate the problem.
    Just posting for the forum users.

    See attached screen shot.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Jan 2011 Link to this post

    Hello Kellie,


    I could replicate the issue in my end. Fortunately, I found a work-around for the issue. I am sharing the code.

    Code:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            var editItem = ((GridDataItem)e.Item);
            var deleteButton = (LinkButton)editItem["DeleteColumn"].Controls[0];
            if (deleteButton != null)
            {
                deleteButton.Enabled = false;
                deleteButton.Attributes.Add("onclick", "JavaScript:void(0);");  // To prevent showing confirm for button
            }
        }
    }



    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kellie
    Kellie avatar
    29 posts
    Member since:
    Feb 2009

    Posted 06 Jan 2011 Link to this post

    Works Beautifully, thanks Princy - wish I could give you some Telerik points ;)
Back to Top