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

Sys.InvalidOperationException: Sys.InvalidOperationException: A control is already associated with the element.

1 Answer 296 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 12 Feb 2014, 09:16 AM
hi,
"Sys.InvalidOperationException: Sys.InvalidOperationException: A control is already associated with the element." i have this error on delete button click inside grid.so provide solutions.

my code is:
function deletepermission(id) {
        
          var add = $("#" + "<%=Per_delete.ClientID %>").val();
          if (add == 0) { bootbox.alert("You have no permissions to Update Record");}
          else {
            bootbox.confirm("Are you sure you want to Delete the Record?", function (result) {
                if (result == true) {
                    $("#" + "<%=gridId.ClientID %>").val(id);
                    $("#" + "<%=btn_Delete_actual.ClientID %>").click();
                  }

              });
           }         
      }


<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="Action" HeaderText="Action" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
                                                                        <ItemTemplate>                                                                          
                                                                            <asp:Button runat="server" ID="btnDelete" ToolTip="DeleteRecord"  Text="Delete" onclientclick='<%# Eval("LandlordId","deletepermission({0})") %>' Height="22px"></asp:Button>
                                                                       
                                                                        
                                                                        </ItemTemplate>                                                           
                                                                    </telerik:GridTemplateColumn>


 <asp:Button runat="server" ID="btn_Delete_actual" onclick="btn_Delete_actual_Click" style="display:none;"></asp:Button>                 
 <asp:HiddenField ID="gridId" runat="server"></asp:HiddenField>


serverside code:
protected void btn_Delete_actual_Click(object sender, EventArgs e)
        {
            int lid = Convert.ToInt32(gridId.Value);
            if (lid > 0)
            {
                if (s.DeleteLandlord(lid) == true)
                {
                    msg.Style.Add("display", "block");
                    lbl_msg.Text = "Record Deleted sucsessfully..";
                    lbl_msg.Style.Add("color", "green");
                    GetLandlord();
                }
            }                 
        }

Thanks,
Rahul

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Feb 2014, 10:44 AM
Hi Rahul,

This is a general MS AJAX error. Could you please try the solution suggested here:
A control is already associated with the element

Thanks,
Princy
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or