I have the button:
<asp:Button runat="server" OnClientClick="return ValidateNewMessage();" OnClick="PostComment" ID="AddCommentButton" CssClass="nice-button" Text="Add Your Comment" />
It is on the URL:
blog/42/gregre-re-greg-er-g/comments-6#comments
When I click the button, it takes me to:
blog/42/gregre-re-greg-er-g/comments-6?ID=42&comments=1&page=6
This is making my scripts work strangely, I really need the button to just keep it's URL format and not include the querystring data, is this possible easily? So fater clicking it, the page is still:
blog/42/gregre-re-greg-er-g/comments-6#comments
The post comment method is as follows:
/// <summary>
/// Post a comment
/// </summary>
public void PostComment(object sender, EventArgs e)
{
CommentResponse CommentResp = CommentCommon.NewComment(NewComment.Text, this.ThisUser.UserID, this.Anchor);
if (!this.ThisUser.IsLoggedIn)
CommentResp.Status = CommentError.NotLoggedIn;
// Error messages
if (CommentResp.Status == CommentError.CommentsPostedTooQuick)
{
DiscussError.Visible = true;
DiscussErrorMessage.Text = "You are posting comments too quickly";
}
else if (CommentResp.Status == CommentError.ExceededCommentsPer3Mins)
{
DiscussError.Visible = true;
DiscussErrorMessage.Text = " You are posting comments too quickly";
}
else if (CommentResp.Status == CommentError.NotEnoughChars)
{
DiscussError.Visible = true;
DiscussErrorMessage.Text = "Comment is not long enough";
}
else if (CommentResp.Status == CommentError.NotLoggedIn)
{
DiscussError.Visible = true;
DiscussErrorMessage.Text = "You are not logged in";
}
else if (CommentResp.Status == CommentError.UnspecifiedError)
{
DiscussError.Visible = true;
DiscussErrorMessage.Text = "Unspecified error.";
}
// Posted ok, redirect to last page
if (CommentResp.Status == CommentError.Success)
{
int TotalComments = CommentCommon.CountComments(this.Anchor);
int TotalPages = (TotalComments + Settings.CommentsPerPage - 1) / Settings.CommentsPerPage;
Response.Redirect(this.PageNavURL.Replace("$1", TotalPages.ToString()) + "#comments");
}
}
The problem occurs when the status ISN'T success, when it redirects it works fine.