This project is read-only.

Make Comment with info from already logged in user

Topics: Controls
Apr 4, 2011 at 3:41 AM
Edited Apr 7, 2011 at 2:36 PM

Hi Adventurers,

I've been digging into js and .net code this evening, but I just don't realize how to modify validateAndSubmitCommentForm function to automatically save the comment with information of the already logged in user.. (comments are disabled for unauthenticated users)...

I've seen that Mads Kristensen has this functionality implemented on his own blog..., how has he achieved it? Is it in the settings and I have missed it somehow?..

Thanks for your help

Apr 15, 2011 at 8:06 AM


I had to switch some parts of source code in file "User controls/CommentView.ascx.cs", just like this:

private void GetCookie()
var cookie = this.Request.Cookies["comment"];
if (Security.IsAuthenticated)
var user = Membership.GetUser();
if (user != null)
this.DefaultName = user.UserName;
this.txtEmail.Text = user.Email;
this.txtWebsite.Text = this.Request.Url.Host;
else if (cookie != null)
this.DefaultName = this.Server.UrlDecode(cookie.Values["name"]);
this.txtEmail.Text = cookie.Values["email"];
this.txtWebsite.Text = cookie.Values["url"];
this.ddlCountry.SelectedValue = cookie.Values["country"];
catch (Exception)
// Couldn't retrieve info on the visitor/user

Hope it is that you looking for. Please excuse my English, I had no practice for a long time.

Apr 18, 2011 at 1:59 PM

Hi Ice13, and thanks for your answer,

I solved this adding this line:

<input type="text" name="<%= this.NameInputId %>" id="<%= this.NameInputId %>" tabindex="2" value="<%= Page.User.Identity.Name %>" />

Thanks again!