UPDATE: One thing I forgot to mention in the post below is that the modification described will apply to
all communities within the CSK install that you modify. Greetings all, At the risk of having this obsoleted by the next release of the CSK, here are the steps required to add the ability to delete users from the Edit Users administration section (these
instructions are for the VBSDK version, but the others should be similar): - Modify the file Default.aspx, located in \CommunityStarterKitVBSDK\Admin\EditUsers\, as follows(note the comments, and that this code also includes a modification to display all users
by default, rather than just those beginning with 'a'):
<script runat=>
Sub OrderChanged(s As Object, e As EventArgs)
UserList.CurrentPageIndex = 0
End Sub 'OrderChanged
Sub UserList_PageIndexChanged(s As Object, e As DataGridPageChangedEventArgs)
UserList.CurrentPageIndex = e.NewPageIndex
End Sub 'UserList_PageIndexChanged
'*******************************************************
'
' Bind matching users to DataGrid.
'
'*******************************************************
Protected Overrides Sub OnPreRender(e As EventArgs)
UserList.DataSource = AdminUtility.GetUsersForLetter(ctlAlphaPicker.SelectedLetter, Int32.Parse(dropSortBy.SelectedItem.Value), Int32.Parse(dropOrderBy.SelectedItem.Value))
UserList.DataBind()
End Sub 'OnPreRender
</script>
"Edit Users" Runat="Server"/>
"75%" cellspacing="0" cellpadding="0" border="0">
"left" valign="top">
Edit Users
The Edit Users page allows you to add, edit, delete, or view information about the users in your community.
You can view all users at once, or alphabetically by letter. Furthermore, you can sort your results by username, the user's full name, or by the date joined.
To edit a user, click on the desired username.
From this page, you can also create, edit, or delete roles for your users. Roles can be used to prohibit all but selected users from secure areas in your community.
For example, you may want to only allow users with 'Gold' book club status to access the book club community. To create a new role, click the
Edit Role link.
<form runat=>
"100%">
by default. Original Tag below.
"ctlAlphaPicker" OnLetterChanged="OrderChanged" Runat="Server" />
--%>
"ctlAlphaPicker" SelectedLetter="All" OnLetterChanged="OrderChanged" Runat="Server" />
Sort By:
"dropSortBy" AutoPostBack="True" OnSelectedIndexChanged="OrderChanged" Runat="Server">
"Username" Value="0"/>
"Full Name" Value="1"/>
"Date Joined" Value="2"/>
Order By:
"dropOrderBy" AutoPostBack="True" OnSelectedIndexChanged="OrderChanged" Runat="Server">
"Ascending" value="0" />
"Descending" value="1" />
"UserList"
width="100%" AutoGenerateColumns="False" AllowPaging="True" OnPageIndexChanged="UserList_PageIndexChanged" PageSize="20"
PagerStyle-Mode="NumericPages" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" BackColor="White"
CellPadding="3"
GridLines="Vertical" Runat="Server">
"True" BackColor="#DCDDDE">
"#dddddd">
"User_Username" DataNavigateUrlField="User_Username" DataNavigateUrlFormatString="EditUser.aspx?username={0}" HeaderText="Username"/>
"FullName" HeaderText="Full Name"/>
"User_DateCreated" DataFormatString="{0:d}" HeaderText="Date Joined"/>
"Delete User" DataNavigateUrlField="User_Username" DataNavigateUrlFormatString="DeleteUser.aspx?username={0}" HeaderText="Delete?"/>
"3" cellspacing="0" border="0" class="body">
"EditRoles.aspx">Edit Roles
|
"..\Default.aspx">Return to Admin
|
"..\..\Default.aspx">Return to Site
</form>
- Add a file called DeleteUser.aspx, containing the following code, to the \CommunityStarterKitVBSDK\Admin\EditUsers\ folder:
<%@ Page Language="VB" smartnavigation="true" %>
<%@ Register TagPrefix="community"Namespace="ASPNET.StarterKit.Communities"Assembly="ASPNET.StarterKit.Communities" %>
<%@ Register TagPrefix="communityAdmin" TagName="RolePicker" Src="..\Controls\RolePicker.ascx" %>
<%@ Register TagPrefix="User" TagName="AdminHeader" Src="~/Admin/Controls/AdminHeader.ascx" %>
<%@ import Namespace="ASPNET.StarterKit.Communities.Admin" %>
<script runat=>
'*******************************************************
'
' When the page first loads, set the username label
' text and the domain label text to the appropriate
' values.
'
'*******************************************************
Sub Page_Load(s AsObject, e As EventArgs)
IfNot Page.IsPostBack Then'Note that if we were storing this value in a database
' we would need to check it for script or other unexpected input!
UserName.Text = Request.QueryString("username")
Domain.Text = CommunityUtility.GetCommunityInfo().Domain
EndIfEndSub'Page_Load
'*******************************************************
'
' Delete the user from the database.
'
'*******************************************************
Sub btnDelete_Click(s AsObject, e As EventArgs)
Try
UserUtility.DeleteUser(Request.QueryString("username"))
Catch ex As Exception
ErrorUtility.RecordError("DeleteUser Error", ex)
EndTry
Response.Redirect("Default.aspx")
EndSub'btnDelete_Click
</script>
"Delete User" Runat="Server" />
Delete User from "Domain" runat="server"/>
On this page, you can delete a user's profile.
<form runat=>
To delete user "UserName" runat="server"/> from this community, click the Delete User button below.
G Andrew Dut...
Member
227 Points
46 Posts
ASPInsiders
MOD: Add DeleteUser functionality
Apr 04, 2003 09:51 PM|LINK
<script runat=> Sub OrderChanged(s As Object, e As EventArgs) UserList.CurrentPageIndex = 0 End Sub 'OrderChanged Sub UserList_PageIndexChanged(s As Object, e As DataGridPageChangedEventArgs) UserList.CurrentPageIndex = e.NewPageIndex End Sub 'UserList_PageIndexChanged '******************************************************* ' ' Bind matching users to DataGrid. ' '******************************************************* Protected Overrides Sub OnPreRender(e As EventArgs) UserList.DataSource = AdminUtility.GetUsersForLetter(ctlAlphaPicker.SelectedLetter, Int32.Parse(dropSortBy.SelectedItem.Value), Int32.Parse(dropOrderBy.SelectedItem.Value)) UserList.DataBind() End Sub 'OnPreRender </script> "Edit Users" Runat="Server"/> "75%" cellspacing="0" cellpadding="0" border="0"> "left" valign="top">- Add a file called DeleteUser.aspx, containing the following code, to the \CommunityStarterKitVBSDK\Admin\EditUsers\ folder:Edit Users
The Edit Users page allows you to add, edit, delete, or view information about the users in your community. You can view all users at once, or alphabetically by letter. Furthermore, you can sort your results by username, the user's full name, or by the date joined. To edit a user, click on the desired username. From this page, you can also create, edit, or delete roles for your users. Roles can be used to prohibit all but selected users from secure areas in your community. For example, you may want to only allow users with 'Gold' book club status to access the book club community. To create a new role, click the Edit Role link. <form runat=> "100%"> by default. Original Tag below. "ctlAlphaPicker" OnLetterChanged="OrderChanged" Runat="Server" /> --%> "ctlAlphaPicker" SelectedLetter="All" OnLetterChanged="OrderChanged" Runat="Server" /> Sort By: "dropSortBy" AutoPostBack="True" OnSelectedIndexChanged="OrderChanged" Runat="Server"> "Username" Value="0"/> "Full Name" Value="1"/> "Date Joined" Value="2"/> Order By: "dropOrderBy" AutoPostBack="True" OnSelectedIndexChanged="OrderChanged" Runat="Server"> "Ascending" value="0" /> "Descending" value="1" /> "UserList" width="100%" AutoGenerateColumns="False" AllowPaging="True" OnPageIndexChanged="UserList_PageIndexChanged" PageSize="20" PagerStyle-Mode="NumericPages" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Vertical" Runat="Server"> "True" BackColor="#DCDDDE"> "#dddddd"> "User_Username" DataNavigateUrlField="User_Username" DataNavigateUrlFormatString="EditUser.aspx?username={0}" HeaderText="Username"/> "FullName" HeaderText="Full Name"/> "User_DateCreated" DataFormatString="{0:d}" HeaderText="Date Joined"/> "Delete User" DataNavigateUrlField="User_Username" DataNavigateUrlFormatString="DeleteUser.aspx?username={0}" HeaderText="Delete?"/> "3" cellspacing="0" border="0" class="body"> "EditRoles.aspx">Edit Roles | "..\Default.aspx">Return to Admin | "..\..\Default.aspx">Return to Site </form>