I am working on a control for [csl] where I need to capture the email address of the person making a comment. However, I don't need to store the email address if the person is already a registered member of the site since this information is stored already. What I did was utilize the CustomAction feature for the WeblogPostCommentForm and set the "AuthorEmail" extended attribute.

Here is how you can do it.

On the /themes/blogs/[default]/Post.aspx page locate your WeblogPostCommentForm and set the following:


CSControl:CustomAction runat="server" OnCustomEvent="CommentFormSuccess" />

This will wireup the call to this function that you must add to the top of the page:

protected void CommentFormSuccess(System.Web.UI.Control sender, object parameter)
CommunityServer.Blogs.Components.WeblogPost post = parameter as CommunityServer.Blogs.Components.WeblogPost;
if (post == null)
if (!post.User.IsAnonymous)
CommunityServer.Blogs.Controls.WeblogPostCommentForm form = sender as CommunityServer.Blogs.Controls.WeblogPostCommentForm;
if (form == null)
System.Web.UI.WebControls.TextBox email = WeblogControlUtility.Instance().FindControl(form, "tbEmail") as System.Web.UI.WebControls.TextBox;
if (email == null)
if (String.IsNullOrEmpty(email.Text))
post.SetExtendedAttribute("AuthorEmail", email.Text);

The final step would be to add in the TextBox to prompt for the users email. What I did was wrap it up in a placeholder and only show it for non-RegisteredUsers.

<CSControl:PlaceHolder runat="server">
<DisplayConditions Operator="Not">
<CSControl:UserInRoleCondition runat="server" Role="Registered Users" UseAccessingUser="true" />
<div class="CommonFormFieldName">
<em>(<CSControl:ResourceControl runat="server" ResourceName="Optional" />)</em>
<div class="CommonFormField">
<asp:TextBox id="tbEmail" runat="server" Columns="60" />
<asp:RequiredFieldValidator id="emailValidator" runat="server" ControlToValidate="tbEmail" Cssclass="validationWarning">*</asp:RequiredFieldValidator>

Now, when someone enters in their email address it will be stored in the ExtendedAttributes of the post.

Read on to see how I use this information.

Comments (2) -


I'm an anonymous user with a gravatar!

Ben Tiedt

Cool use of the CustomAction!  You could also use a SubForm control to implement this behavior and prevent the double-save.

Comments are closed