Has anyone implemented AJAX blog comments with .net AJAX extensions? Options
darrenjferguson
Posted: Thursday, June 19, 2008 10:34:36 AM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
Hello All,

I am wondering if anyone has had a go at implementing AJAX blog comments with the asp.net AJAX extensions - I know Peter D did something using another AJAX provider.

I've found it easy enough to create an unobtrusive form, but am a little stuck with how I would update the list of comments on my page to include the new comment.

The issue as far as I can see is that my comment list is created using an XSLT Macro and my AJAX form is a .net user control.

I can see a hacky way of writing some javascript to manipulate the document once a comment has been added, but it does seem to be a hack.

Has anyone got any suggestions, would the best way to be to combine the comments list and form into a single user control?

Thanks in advance.


Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
warren
Posted: Thursday, June 19, 2008 11:46:14 AM

Rank: Addict

Joined: 7/19/2006
Posts: 777
Location: Leigh-on-Sea, Essex, UK
I would be interested in the solution to this. As my comment form is a .NET usercontrol and the list of comments is rendered by XSLT as well.

Can we use jQuery at all, to modify the DOM and insert the comment?

Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
PeterD
Posted: Thursday, June 19, 2008 11:49:49 AM

Rank: Fanatic

Joined: 7/20/2006
Posts: 480
Location: NL
Hey Darren,

on my blog I use Doc2Form (latest version from codeplex).
With that you can define to use Ajax or not. That's really all I did, no hacks or whatsoever ;-)

HTH,
PeterD

Working on an events-calendar with recursion. Post requests on my blog!
PeterD
Posted: Thursday, June 19, 2008 11:58:43 AM

Rank: Fanatic

Joined: 7/20/2006
Posts: 480
Location: NL
Here's the code I use in my template:

<?UMBRACO_MACRO macroAlias="Doc2FormComplete" DocumentType="1043" Template="" TabName="data" PageTabs="0" HideTabNames="1" ChooseWhereToStore="[#pageID]" EditMode="0" ShowTitle="0" TitleName="" SaveMemberAlias=", " ShowDescriptions="1" SubmitButtonText="Leave comment" PreviousButtonText="" NextButtonText="" RequiredText="Mandatory fields" TextOnSubmit="Thanks for comment" PublishOnSubmit="1" RefreshToParent="1" RedirectToNode="" PublishWithUserId="0" StorePropertiesInCookies="email, name, website" SendEmailResponse="0" ResponseSubject="" ResponseMessage="" ResponseEmailFieldAlias=", " ResponseCopyTo="" EmailForm="0" FormSubject="" FormMessage="" FormToEmailAddress="" FormFromEmailAddress="" UseAjax="1" DefaultValueNode=""></?UMBRACO_MACRO>


Working on an events-calendar with recursion. Post requests on my blog!
darrenjferguson
Posted: Thursday, June 19, 2008 12:08:44 PM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
warren wrote:
Can we use jQuery at all, to modify the DOM and insert the comment?


Yes, that is what i was considering.

I guess you'd just need to insert the new post content in a hidden element of the response and then update your comments list with Jquery... It seems a little bit of a hack...

Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
darrenjferguson
Posted: Thursday, June 19, 2008 12:09:40 PM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
PeterD wrote:

on my blog I use Doc2Form (latest version from codeplex).
With that you can define to use Ajax or not. That's really all I did, no hacks or whatsoever ;-)


Hi Peter, are you talking about http://umbraco.bruunebonen.com

I just posted a comment and it seemed to do a complete page refresh....

Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
tim
Posted: Thursday, June 19, 2008 12:14:22 PM

Rank: Addict

Joined: 2/19/2007
Posts: 731
Location: Belgium
I'm not sure but I think BlogEngine.NET ( http://www.dotnetblogengine.net/ ) has ajax comments, maybe you could take a look at the source to find out in what way they are doing it ...

Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
tim
Posted: Thursday, June 19, 2008 12:16:48 PM

Rank: Addict

Joined: 2/19/2007
Posts: 731
Location: Belgium
Also something to check out:

http://www.cpalm.dk/blog/2006/07/22/please-make-a-comment.aspx#acreatecomment


Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
darrenjferguson
Posted: Thursday, June 19, 2008 12:26:03 PM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
tim wrote:
Also something to check out:

http://www.cpalm.dk/blog/2006/07/22/please-make-a-comment.aspx#acreatecomment


Ah, I was mistaking Peters blog with Christians....



Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
warren
Posted: Thursday, June 19, 2008 12:32:20 PM

Rank: Addict

Joined: 7/19/2006
Posts: 777
Location: Leigh-on-Sea, Essex, UK
I don't see how jQuery and modifying the DOM is a hack - that's what AJAX is about :)

The problem I see is how do you gracefully rollback if the user has JS disabled which is the more important thing, so it will work with JS on or off.

Warren

Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
darrenjferguson
Posted: Thursday, June 19, 2008 12:44:50 PM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
warren wrote:

The problem I see is how do you gracefully rollback if the user has JS disabled which is the more important thing, so it will work with JS on or off.


The ASP.net ajax extensions take care of that for you, If JS is disabled it will just do a standard request which performs the same functionality.

I got that part working yesterday.

I'm just wondering if Casey's Doc2Form would allow us to do some kind of Javascript callback, with the post content formatted as JSON or XML....

Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
darrenjferguson
Posted: Thursday, June 19, 2008 12:46:19 PM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
warren wrote:
I don't see how jQuery and modifying the DOM is a hack - that's what AJAX is about


Actually, you are right. Let me try and rephrase. I'm not sure how to get dotnet to pass back the contents of a form submission to a javascript callback in a nice way.

I'm also not sure where formatting the post to markup should occur.

Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
warren
Posted: Thursday, June 19, 2008 1:38:03 PM

Rank: Addict

Joined: 7/19/2006
Posts: 777
Location: Leigh-on-Sea, Essex, UK
I'll explain my scenario I would like.

* User fills in .NET usercontrol comment form
* user submits form then usercontrol checks for spam using 3rd party service
* creates node from usercontrol if approved as not spam
* if JS enabled then add comment using jQuery (somehow - i dont know)
* otherwise if JS disabled use postback method

If anybody has suggestions/ideas I would love to hear them please.

Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
darrenjferguson
Posted: Thursday, June 19, 2008 1:43:44 PM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
The more I look at this, the more I think that the ideal solution would be that Casey's Doc2Form package had an extra parameter that allowed you to specify a javascript callback function - or maybe two, one for error and one for success.

When a successful submission happens, I would suggest that the specified callback gets passed the form values as JSON.

It would then be up to you to update the document as appropriate....
Are you listening Casey ;)

I'll try and prototype something when I have a moment.


Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
warren
Posted: Thursday, June 19, 2008 1:46:12 PM

Rank: Addict

Joined: 7/19/2006
Posts: 777
Location: Leigh-on-Sea, Essex, UK
I'm not sure I would want to use doc2Form. In my case my usercontrol goes off to a Askimet Spam service to check the comment, but I will be interested to see what comes out of this.

Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
neehouse
Posted: Thursday, June 19, 2008 6:30:47 PM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,074
Location: Charleston, West Virginia, United States
@darren - feel free to modify the code, and if it works well, I will consider adding it. There may be other ways to trick out doc2form to do what you want, such as formatting the thank you message to look like what you want. just be careful of commas.

@warren - many of those services are great, but, can also be overkill, as they are services. I personally do not like relying on 3rd party servers as if they go down, then you are dead. Most spam bots fail with ajax enabled. Another method is to not show the form initially, but only after a click to show. However, a few umbraco controls don't like that either (datepicker, js based controls).

Let me know what you end up with.

Case

• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
warren
Posted: Thursday, June 19, 2008 6:35:22 PM

Rank: Addict

Joined: 7/19/2006
Posts: 777
Location: Leigh-on-Sea, Essex, UK
Im using the Askimet service that is powered behind WordPress so its a relatively stable and I haven't had any problems with them (that I'm aware of)

Warren

Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
PeterD
Posted: Thursday, June 19, 2008 6:58:10 PM

Rank: Fanatic

Joined: 7/20/2006
Posts: 480
Location: NL
darrenjferguson wrote:

Hi Peter, are you talking about http://umbraco.bruunebonen.com

I just posted a comment and it seemed to do a complete page refresh....


Yes, that's my blog ;-)
True, it does a page-refresh after posting, didn't have time to figure out to get the comment added to the page without the reload to be honest.
What Tim suggested was what I had in mind at first too (Christians example) but I struggled too much with it to get it working and I sort of abandonded it........

But, I like the idea, and it sure would be a benefit for a comments-form I think.

PeterD


Working on an events-calendar with recursion. Post requests on my blog!
darrenjferguson
Posted: Friday, June 20, 2008 10:13:37 AM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
neehouse wrote:
Most spam bots fail with ajax enabled.


I'd like anything that I created to be unobtrusive so work with or without JS....

The .net UpdatePanel seems to take care of most of this, I'm just trying to figure out callbacks....

D.

Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
warren
Posted: Friday, June 20, 2008 10:23:24 AM

Rank: Addict

Joined: 7/19/2006
Posts: 777
Location: Leigh-on-Sea, Essex, UK
I haven't done much with ASP.NET AJAX.
Does it produce horrible markup and how well does it degrade gracefully?

Let me know what you find out Darren.

//Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.