I have use the code/setup from the video about making a Comment System.
I have a little problem, when the user has submitted a comment, i would like to have the page reloaded, so the user can see their own comments at once.
I have tried to make my own workflow plugin, it does reload the page, but because the workflow plugin does not return like it should due to redirect, the page acts quite strange.
How can i get the page to reload it self after a submit. I have tried to use the build in 'post/get a URL' workflow item, but i have no clue how to specify the URL of the current page.
Due to a little help from another post, i made an event, to handle this:
using System.Web; using Umbraco.Forms.Core; using Umbraco.Forms.Core.Services;
namespace IntraConnect.actionhandlers { public class FormRecordEventHandler : umbraco.BusinessLogic.ApplicationBase { public FormRecordEventHandler() { RecordService.RecordApproved += RecordService_RecordApproved; }
void RecordService_RecordApproved(object sender, RecordEventArgs e) { if (e.Form.Name == "Comment Form") { var context = HttpContext.Current; string url = context.Request.Url.AbsoluteUri;
context.Response.Redirect(url); } } } }
The page is nicely reloaded after the post, but if i submit another comment, it will just overwrite the latest comment i posted. Instead of adding a new comment.
I know it is not often people add multiple comments to a post, but i am sure some people would do it ;-)
I fail to see how that should do any difference, that is what i am doing already, except the code i use, figures out what page it is on, so i don't have to typ in the URL, the form is on many pages.
The main problem, is that the 'submit' after the page has reloaded, just overwrites the last form post, for some weird reason.
Reload page after submit
I have use the code/setup from the video about making a Comment System.
I have a little problem, when the user has submitted a comment, i would like to have the page reloaded, so the user can see their own comments at once.
I have tried to make my own workflow plugin, it does reload the page, but because the workflow plugin does not return like it should due to redirect, the page acts quite strange.
How can i get the page to reload it self after a submit. I have tried to use the build in 'post/get a URL' workflow item, but i have no clue how to specify the URL of the current page.
Due to a little help from another post, i made an event, to handle this:
using System.Web;
using Umbraco.Forms.Core;
using Umbraco.Forms.Core.Services;
namespace IntraConnect.actionhandlers
{
public class FormRecordEventHandler : umbraco.BusinessLogic.ApplicationBase
{
public FormRecordEventHandler()
{
RecordService.RecordApproved += RecordService_RecordApproved;
}
void RecordService_RecordApproved(object sender, RecordEventArgs e)
{
if (e.Form.Name == "Comment Form")
{
var context = HttpContext.Current;
string url = context.Request.Url.AbsoluteUri;
context.Response.Redirect(url);
}
}
}
}
The page is nicely reloaded after the post, but if i submit another comment, it will just overwrite the latest comment i posted. Instead of adding a new comment.
I know it is not often people add multiple comments to a post, but i am sure some people would do it ;-)
Please help.
Try this.
Response.Redirect("~/yourPage.aspx");
Hi Bruno
Thanks for your answer.
I fail to see how that should do any difference, that is what i am doing already, except the code i use, figures out what page it is on, so i don't have to typ in the URL, the form is on many pages.
The main problem, is that the 'submit' after the page has reloaded, just overwrites the last form post, for some weird reason.
If you wrap the RenderForm.ascx in your own user control you can inspect the value of the literal writing the Message on submit text.
For wrapping see http://our.umbraco.org/forum/umbraco-pro/contour/9519-Don't-display-form-based-on-cookie-value
In your user control you then override OnPreRender and do something like this
Not tested with your problem with overwriting last form posts but this should do the job.
Hello Harald
Thanks a lot for your help.
I got it to work now :-) Also the 'overwriting part'.
is working on a reply...