protected void AnswerSubmitCommentButton_OnClick(object sender, EventArgs e) { var logginedUser = HttpContext.Current.User.Identity; if (logginedUser.IsAuthenticated) // only logedin users can comment on answers { var submitButton = (Button)sender; var answerId = int.Parse(submitButton.CommandArgument); var commentTextBox = (TextBox)submitButton.Parent.FindControl("AnswerCommentBody"); using (var control = new AnswerController()) { control.AddComment(answerId, commentTextBox.Text); } AnswersList.DataBind(); } else { var currentUrl = HttpUtility.UrlEncode(Request.Url.PathAndQuery); Response.Redirect($"~/Login.aspx?ReturnUrl={currentUrl}"); } }