Skip to content

Commit

Permalink
ask for confirmation before deleting connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvand committed May 7, 2024
1 parent ab6b8a6 commit e0dbbad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Yvand.LDAPCPSE/TEMPLATE/ADMIN/LDAPCPSE/GlobalSettings.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@
<Template_InputFormControls>
<tr>
<td>
<wssawc:SPGridView runat="server" ID="grdLDAPConnections" AutoGenerateColumns="false" OnRowDeleting="grdLDAPConnections_RowDeleting">
<wssawc:SPGridView runat="server" ID="grdLDAPConnections" AutoGenerateColumns="false" OnRowDeleting="grdLDAPConnections_RowDeleting" OnRowDataBound="grdLDAPConnections_RowDataBound">
<Columns>
<asp:BoundField DataField="Id" ItemStyle-CssClass="ldapcp-HideCol" HeaderStyle-CssClass="ldapcp-HideCol" />
<asp:BoundField HeaderText="LDAP Path" DataField="Path" />
<asp:BoundField HeaderText="Username" DataField="Username" />
<asp:CommandField HeaderText="Action" ButtonType="Button" DeleteText="Remove" ShowDeleteButton="True" />
<asp:CommandField HeaderText="Action" ButtonType="Button" DeleteText="Delete" ShowDeleteButton="True" />
</Columns>
</wssawc:SPGridView>
</td>
Expand Down
15 changes: 14 additions & 1 deletion Yvand.LDAPCPSE/TEMPLATE/ADMIN/LDAPCPSE/GlobalSettings.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ protected void Initialize()
LabelMessage.Text = String.Format(TextSummaryPersistedObjectInformation, Configuration.Name, Configuration.Version, Configuration.Id);
UserIdentifierEncodedValuePrefix = base.UserIdentifierEncodedValuePrefix;
GroupIdentifierEncodedValuePrefix = base.GroupIdentifierEncodedValuePrefix;
PopulateConnectionsGrid();
if (!this.IsPostBack)
{
PopulateConnectionsGrid();
PopulateCblAuthenticationTypes();
PopulateFields();
InitializeAugmentation();
Expand Down Expand Up @@ -401,6 +401,19 @@ void AddTenantConnection()
this.TxtLdapUsername.Text = String.Empty;
this.TxtLdapPassword.Text = String.Empty;
}

protected void grdLDAPConnections_RowDataBound(object sender, GridViewRowEventArgs e)
{
// Ask user for confirmation when cliking on button Delete - https://stackoverflow.com/questions/9026884/asp-net-gridview-delete-row-only-on-confirmation
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button deleteButton = (Button)e.Row.Cells[3].Controls[0];
if (deleteButton != null && String.Equals(deleteButton.Text, "Delete", StringComparison.OrdinalIgnoreCase))
{
deleteButton.OnClientClick = "if(!confirm('Are you sure you want to delete this directory?')) return;";
}
}
}
}

public class PropertyCollectionBinder
Expand Down

0 comments on commit e0dbbad

Please sign in to comment.