У меня есть кнопка:
<asp:Button runat="server" OnClientClick="return ValidateNewMessage();" OnClick="PostComment" ID="AddCommentButton" CssClass="nice-button" Text="Add Your Comment" />
Это по URL:
blog/42/gregre-re-greg-er-g/comments-6#comments
Когда я нажимаю кнопку, я получаю:
blog/42/gregre-re-greg-er-g/comments-6?ID=42&comments=1&page=6
Это делает мои скрипты странными, мне действительно нужна кнопка, чтобы просто сохранить ее формат URL и не включать данные строки запроса, это возможно легко? Так что, нажав ее, страница по-прежнему:
blog/42/gregre-re-greg-er-g/comments-6#comments
Метод комментария к записи следующий:
/// <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");
}
}
Проблема возникает, когда статус НЕ работает, когда он перенаправляет, он работает нормально.