add comments not working

Topics: ASP.NET 2.0
Dec 15, 2010 at 4:10 PM

I have installed version 1.6.1 and everything is working perfectly except no one can add comments. It doesn't matter what browser I am in. Once I press "save comment" nothing happens. Not even the saving animation. Just nothing.

In IE I get a javascript error even before pressing save:

 

Syntax Error

js.asd

Object Expected
Money-Back-Guarantee.aspx

'dp' is undefined
Money-Back-Guarantee.aspx
Code: 0
URI: http://agent.atlei.com/agentblog/post/Money-Back-Guarantee.aspx

 

and then after hitting save I get this:

Object Expected
js.asd
code: 0
URI: http://agent.atlei.com/agentblog/js.axd?path=%2fagentblog%2fblog.js&v=1.6.1.0

 

I have been searching the forums all morning. I saw where others had problems but it was browser related or earlier versions of Blog Engine. Does anyone have any ideas what is causing this.

Dec 15, 2010 at 4:34 PM

In Firebug I get similar errors:

WebForm_InitCallback is not defined

dp is not defined
I notice now that these errors are occuring on every page, but the only thing it is preventing me from doing is adding comments. I can add/edit posts, change settings and everything else just fine.
Coordinator
Dec 15, 2010 at 5:53 PM

In the control panel, on the Settings tab under Advanced Settings, uncheck "Compress WebResource.axd".  That should help with these errors or some of them.

Dec 15, 2010 at 6:38 PM

Still not luck. I get this in firebug now

BlogEngine.comments.nameBox is null
Coordinator
Dec 15, 2010 at 6:58 PM

If you try to directly navigate in your browser to:

http://agent.atlei.com/agentblog/js.axd?path=%2fagentblog%2fblog.js&v=1.6.1.0

Do you see JavaScript (it'll probably be compressed into one or two lines) ?

I tried going there, but don't have the username/password.  No problem though.

If you don't see JavaScript at the above URL, what do you see ?

Dec 15, 2010 at 7:03 PM

Yes I do see javascript, but it is a lot more than one or two lines. I am going to try to paste it here. Not sure if it will all come through:

 

BlogEngine ={$: function(id){return document.getElementById(id);},webRoot: '',i18n:{hasRated: '',savingTheComment: '',comments: '',commentWasSaved: '',commentWaitingModeration: '',cancel: '',filter: '',apmlDescription: '',beTheFirstToRate: '',currentlyRated: '',ratingHasBeenRegistered: '',rateThisXStars: ''},setFlag: function(iso){if (iso.length > 0)
BlogEngine.comments.flagImage.src = BlogEngine.webRoot + "pics/flags/" + iso + ".png";else BlogEngine.comments.flagImage.src = BlogEngine.webRoot + "pics/pixel.gif";},showCommentPreview: function(){var oPreview = this.$('preview');var oCompose = this.$('compose');if (oPreview) oPreview.className = 'selected';if (oCompose) oCompose.className = '';this.$('commentCompose').style.display = 'none';this.$('commentPreview').style.display = 'block';this.$('commentPreview').innerHTML = '<img src="' + BlogEngine.webRoot + 'pics/ajax-loader.gif" alt="Loading" />';var argument = this.$('commentPreview').innerHTML;this.addComment(true);},composeComment: function(){var oPreview = this.$('preview');var oCompose = this.$('compose');if (oPreview) oPreview.className = '';if (oCompose) oCompose.className = 'selected';this.$('commentPreview').style.display = 'none';this.$('commentCompose').style.display = 'block';},endShowPreview: function(arg,context){BlogEngine.$('commentPreview').innerHTML = arg;},toggleCommentSavingIndicators: function(bSaving){BlogEngine.$("btnSaveAjax").disabled = bSaving;BlogEngine.$("ajaxLoader").style.display = bSaving ? "inline" : "none";BlogEngine.$("status").className = "";BlogEngine.$("status").innerHTML = "";if (!bSaving){BlogEngine.$('commentPreview').innerHTML = "";BlogEngine.composeComment();}},onCommentError: function(error,context){BlogEngine.toggleCommentSavingIndicators(false);error = error || "Unknown error occurred.";var iDelimiterPos = error.indexOf("|");if (iDelimiterPos > 0){error = error.substr(0,iDelimiterPos);while (error.length > 0 && error.substr(error.length - 1,1).match(/\d/)){error = error.substr(0,error.length - 1);}}if( document.getElementById('recaptcha_response_field') ){Recaptcha.reload();}alert("Sorry, the following error occurred while processing your comment:\n\n" + error);},addComment: function(preview){var isPreview = preview == true;if (!isPreview){BlogEngine.toggleCommentSavingIndicators(true);this.$("status").innerHTML = BlogEngine.i18n.savingTheComment;}var author = BlogEngine.comments.nameBox.value;var email = BlogEngine.comments.emailBox.value;var website = BlogEngine.comments.websiteBox.value;var country = BlogEngine.comments.countryDropDown ? BlogEngine.comments.countryDropDown.value : "";var content = BlogEngine.comments.contentBox.value;var notify = BlogEngine.$("cbNotify").checked;var captcha = BlogEngine.comments.captchaField.value;var replyToId = BlogEngine.comments.replyToId ? BlogEngine.comments.replyToId.value : "";var recaptchaResponseField = document.getElementById('recaptcha_response_field');var recaptchaResponse = recaptchaResponseField ? recaptchaResponseField.value : "";var recaptchaChallengeField = document.getElementById('recaptcha_challenge_field');var recaptchaChallenge = recaptchaChallengeField ? recaptchaChallengeField.value : "";var avatarInput = BlogEngine.$("avatarImgSrc");var avatar = (avatarInput && avatarInput.value) ? avatarInput.value : "";var callback = isPreview ? BlogEngine.endShowPreview : BlogEngine.appendComment;var argument = author + "-|-" + email + "-|-" + website + "-|-" + country + "-|-" + content + "-|-" + notify + "-|-" + isPreview + "-|-" + captcha + "-|-" + replyToId + "-|-" + avatar + "-|-" + recaptchaResponse + "-|-" + recaptchaChallenge;alert(document.forms[0].action);document.forms[0].action = location.href.replace(location.hash,"");alert(document.forms[0].action);WebForm_DoCallback(BlogEngine.comments.controlId,argument,callback,'comment',BlogEngine.onCommentError,false);if (!isPreview && typeof (OnComment) != "undefined")
OnComment(author,email,website,country,content);},cancelReply: function(){this.replyToComment('');},replyToComment: function(id){BlogEngine.comments.replyToId.value = id;var commentForm = BlogEngine.$('comment-form');if (!id || id == '' || id == null || id == '00000000-0000-0000-0000-000000000000'){var base = BlogEngine.$("commentlist");base.appendChild(commentForm);BlogEngine.$('cancelReply').style.display = 'none';}else{BlogEngine.$('cancelReply').style.display = '';var parentComment = BlogEngine.$('id_' + id);var replies = BlogEngine.$('replies_' + id);if (replies == null){replies = document.createElement('div');replies.className = 'comment-replies';replies.setAttribute('id') = 'replies_' + id;parentComment.appendChild(replies);}replies.style.display = '';replies.appendChild(commentForm);}BlogEngine.comments.nameBox.focus();},appendComment: function(args,context){if (context == "comment"){if( document.getElementById('recaptcha_response_field') ){Recaptcha.reload();}if( args == "RecaptchaIncorrect" ){if( document.getElementById("spnCaptchaIncorrect") ) document.getElementById("spnCaptchaIncorrect").style.display = "";BlogEngine.toggleCommentSavingIndicators(false);}else{if( document.getElementById("spnCaptchaIncorrect") ) document.getElementById("spnCaptchaIncorrect").style.display = "none";var commentList = BlogEngine.$("commentlist");if (commentList.innerHTML.length < 10)
commentList.innerHTML = "<h1 id='comment'>" + BlogEngine.i18n.comments + "</h1>"
var id = BlogEngine.comments.replyToId ? BlogEngine.comments.replyToId.value : '';if (id != ''){var replies = BlogEngine.$('replies_' + id);replies.innerHTML += args;}else{commentList.innerHTML += args;commentList.style.display = 'block';}BlogEngine.comments.contentBox.value = "";BlogEngine.comments.contentBox = BlogEngine.$(BlogEngine.comments.contentBox.id);BlogEngine.toggleCommentSavingIndicators(false);BlogEngine.$("status").className = "success";if (!BlogEngine.comments.moderation)
BlogEngine.$("status").innerHTML = BlogEngine.i18n.commentWasSaved;else BlogEngine.$("status").innerHTML = BlogEngine.i18n.commentWaitingModeration;var commentForm = BlogEngine.$('comment-form');commentList.appendChild(commentForm);if (BlogEngine.comments.replyToId) BlogEngine.comments.replyToId.value = '';if (BlogEngine.$('cancelReply')) BlogEngine.$('cancelReply').style.display = 'none';}}BlogEngine.$("btnSaveAjax").disabled = false;},validateAndSubmitCommentForm: function(){var bBuiltInValidationPasses = Page_ClientValidate('AddComment');var bNameIsValid = BlogEngine.comments.nameBox.value.length > 0;document.getElementById('spnNameRequired').style.display = bNameIsValid ? 'none' : '';var bAuthorNameIsValid = true;if (BlogEngine.comments.checkName){var author = BlogEngine.comments.postAuthor;var visitor = BlogEngine.comments.nameBox.value;bAuthorNameIsValid = !this.equal(author,visitor);}document.getElementById('spnChooseOtherName').style.display = bAuthorNameIsValid ? 'none' : '';if (bBuiltInValidationPasses && bNameIsValid && bAuthorNameIsValid){BlogEngine.addComment();return true;}return false;},addBbCode: function(v){try{var contentBox = BlogEngine.comments.contentBox;if (contentBox.selectionStart){var pretxt = contentBox.value.substring(0,contentBox.selectionStart);var therest = contentBox.value.substr(contentBox.selectionEnd);var sel = contentBox.value.substring(contentBox.selectionStart,contentBox.selectionEnd);contentBox.value = pretxt + "[" + v + "]" + sel + "[/" + v + "]" + therest;contentBox.focus();}else if (document.selection && document.selection.createRange){var str = document.selection.createRange().text;contentBox.focus();var sel = document.selection.createRange();sel.text = "[" + v + "]" + str + "[/" + v + "]";}}catch (ex){}return;},search: function(root){var input = this.$("searchfield");var check = this.$("searchcomments");var search = "search.aspx?q=" + encodeURIComponent(input.value);if (check != null && check.checked)
search += "&comment=true";top.location.href = root + search;return false;},searchClear: function(defaultText){var input = this.$("searchfield");if (input.value == defaultText)
input.value = "";else if (input.value == "")
input.value = defaultText;},rate: function(id,rating){this.createCallback("rating.axd?id=" + id + "&rating=" + rating,BlogEngine.ratingCallback);},ratingCallback: function(response){var rating = response.substring(0,1);var status = response.substring(1);if (status == "OK"){if (typeof OnRating != "undefined")
OnRating(rating);alert(BlogEngine.i18n.ratingHasBeenRegistered);}else if (status == "HASRATED"){alert(BlogEngine.i18n.hasRated);}else{alert("An error occured while registering your rating. Please try again");}},createCallback: function(url,callback){var http = BlogEngine.getHttpObject();http.open("GET",url,true);http.onreadystatechange = function(){if (http.readyState == 4){if (http.responseText.length > 0 && callback != null)
callback(http.responseText);}};http.send(null);},getHttpObject: function(){if (typeof XMLHttpRequest != 'undefined')
return new XMLHttpRequest();try{return new ActiveXObject("Msxml2.XMLHTTP");}catch (e){try{return new ActiveXObject("Microsoft.XMLHTTP");}catch (e){}}return false;},updateCalendar: function(args,context){var cal = BlogEngine.$('calendarContainer');cal.innerHTML = args;BlogEngine.Calendar.months[context] = args;},toggleMonth: function(year){var monthList = BlogEngine.$("monthList");var years = monthList.getElementsByTagName("ul");for (i = 0;i < years.length;i++){if (years[i].id == year){var state = years[i].className == "open" ? "" : "open";years[i].className = state;break;}}},equal: function(first,second){var f = first.toLowerCase().replace(new RegExp(' ','gi'),'');var s = second.toLowerCase().replace(new RegExp(' ','gi'),'');return f == s;},xfnRelationships: ['friend','acquaintance','contact','met','co-worker','colleague','co-resident','neighbor','child','parent','sibling','spouse','kin','muse','crush','date','sweetheart','me'],hightLightXfn: function(){var content = BlogEngine.$('content');if (content == null)
return;var links = content.getElementsByTagName('a');for (i = 0;i < links.length;i++){var link = links[i];var rel = link.getAttribute('rel');if (rel && rel != "nofollow"){for (j = 0;j < BlogEngine.xfnRelationships.length;j++){if (rel.indexOf(BlogEngine.xfnRelationships[j]) > -1){link.title = 'XFN relationship: ' + rel;break;}}}}},showRating: function(container,id,raters,rating){var div = document.createElement('div');div.className = 'rating';var p = document.createElement('p');div.appendChild(p);if (raters == 0){p.innerHTML = BlogEngine.i18n.beTheFirstToRate;}else{p.innerHTML = BlogEngine.i18n.currentlyRated.replace('{0}',new Number(rating).toFixed(1)).replace('{1}',raters);}var ul = document.createElement('ul');ul.className = 'star-rating small-star';div.appendChild(ul);var li = document.createElement('li');li.className = 'current-rating';li.style.width = Math.round(rating * 20) + '%';li.innerHTML = 'Currently ' + rating + '/5 Stars.';ul.appendChild(li);for (var i = 1;i <= 5;i++){var l = document.createElement('li');var a = document.createElement('a');a.innerHTML = i;a.href = 'rate/' + i;a.className = this.englishNumber(i);a.title = BlogEngine.i18n.rateThisXStars.replace('{0}',i.toString()).replace('{1}',i == 1 ? '' : 's');a.onclick = function(){BlogEngine.rate(id,this.innerHTML);return false;};l.appendChild(a);ul.appendChild(l);}container.innerHTML = '';container.appendChild(div);container.style.visibility = 'visible';},applyRatings: function(){var divs = document.getElementsByTagName('div');for (var i = 0;i < divs.length;i++){if (divs[i].className == 'ratingcontainer'){var args = divs[i].innerHTML.split('|');BlogEngine.showRating(divs[i],args[0],args[1],args[2]);}}},englishNumber: function(number){if (number == 1)
return 'one-star';if (number == 2)
return 'two-stars';if (number == 3)
return 'three-stars';if (number == 4)
return 'four-stars';return 'five-stars';},addLoadEvent: function(func){var oldonload = window.onload;if (typeof window.onload != 'function'){window.onload = func;}else{window.onload = function(){oldonload();func();}}},filterByAPML: function(){var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;var height = document.documentElement.clientHeight + document.documentElement.scrollTop;document.body.style.position = 'static';var layer = document.createElement('div');layer.style.zIndex = 2;layer.id = 'layer';layer.style.position = 'absolute';layer.style.top = '0px';layer.style.left = '0px';layer.style.height = document.documentElement.scrollHeight + 'px';layer.style.width = width + 'px';layer.style.backgroundColor = 'black';layer.style.opacity = '.6';layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=60)");document.body.appendChild(layer);var div = document.createElement('div');div.style.zIndex = 3;div.id = 'apmlfilter';div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';div.style.top = '200px';div.style.left = (width / 2) - (400 / 2) + 'px';div.style.height = '50px';div.style.width = '400px';div.style.backgroundColor = 'white';div.style.border = '2px solid silver';div.style.padding = '20px';document.body.appendChild(div);var p = document.createElement('p');p.innerHTML = BlogEngine.i18n.apmlDescription;p.style.margin = '0px';div.appendChild(p);var form = document.createElement('form');form.method = 'get';form.style.display = 'inline';form.action = BlogEngine.webRoot;div.appendChild(form);var textbox = document.createElement('input');textbox.type = 'text';textbox.value = BlogEngine.getCookieValue('url') || 'http://';textbox.style.width = '320px';textbox.id = 'txtapml';textbox.name = 'apml';textbox.style.background = 'url(' + BlogEngine.webRoot + 'pics/apml.png) no-repeat 2px center';textbox.style.paddingLeft = '16px';form.appendChild(textbox);textbox.focus();var button = document.createElement('input');button.type = 'submit';button.value = BlogEngine.i18n.filter;button.onclick = function(){location.href = BlogEngine.webRoot + '?apml=' + encodeURIComponent(BlogEngine.$('txtapml').value)};form.appendChild(button);var br = document.createElement('br');div.appendChild(br);var a = document.createElement('a');a.innerHTML = BlogEngine.i18n.cancel;a.href = 'javascript:void(0)';a.onclick = function(){document.body.removeChild(BlogEngine.$('layer'));document.body.removeChild(BlogEngine.$('apmlfilter'));document.body.style.position = '';};div.appendChild(a);},getCookieValue: function(name){var cookie = new String(document.cookie);if (cookie != null && cookie.indexOf('comment=') > -1){var start = cookie.indexOf(name + '=') + name.length + 1;var end = cookie.indexOf('&',start);if (end > start && start > -1)
return cookie.substring(start,end);}return null;},comments:{flagImage: null,contentBox: null,moderation: null,checkName: null,postAuthor: null,nameBox: null,emailBox: null,websiteBox: null,countryDropDown: null,captchaField: null,controlId: null,replyToId: null}};BlogEngine.addLoadEvent(BlogEngine.hightLightXfn);if (typeof ($) == 'undefined')
window.$ = BlogEngine.$;if (typeof (registerCommentBox) != 'undefined')
BlogEngine.addLoadEvent(registerCommentBox);if (typeof (registerVariables) != 'undefined')
BlogEngine.addLoadEvent(registerVariables);if (typeof (setupBlogEngineCalendar) != 'undefined')
BlogEngine.addLoadEvent(setupBlogEngineCalendar);BlogEngine.addLoadEvent(BlogEngine.applyRatings);
Coordinator
Dec 15, 2010 at 7:42 PM

That looks right ... I was thinking all the line feeds were maybe removed so you would have a really long line.  I just forgot ... what you have looks right.

I was just looking at the one error message you reported:

BlogEngine.comments.nameBox is null

When you pull up an individual blog post, where the Comment form is, if you do a View Source, try searching for "BlogEngine.comments.nameBox".  It should look something like:

BlogEngine.comments.nameBox = BlogEngine.$("txtName634280170230283203");

You can also check the value of "BlogEngine.comments.nameBox" in the Firebug console.

... at this point, I'm not entirely sure what the problem is, so just suggesting ideas on how we can find clues.  I'm sure we can fix it though.

Where is Syntax Highlighter coming from?  We added Syntax Highlighter in BE 2.0, but you are using BE 1.6.1.  Did you add that from here?

If you're using a custom theme, you could try temporarily switching to the Standard Theme to just see if there's any difference (i.e. if it works with that theme).

Dec 15, 2010 at 8:02 PM

First of all, thank you so much for your help. I really appreciate you working with me.

Secondly, I think we are onto something. Before submitting my post here I did try switching back to the standard theme and it did not work either, however when I just now switched back to the standard theme the post is working fine. I think that must be because I unchecked Compress WebResource.axd as you initially suggested.

Now as to the syntax highlighter. I started my theme from the Interlude Theme provided on one of the theme sites. Maybe that is the problem.

The theme site did not say which version they were compatible.
So, I just went into my site.master and removed the syntax javascript code, and now my posts are working fine!! So I guess that interlude theme is for 2.0 only. ??There was not really any documentation on the site.

Thank you so much for your help. It is all working great now! I really love this blog engine. This is the second time I have used it and I forsee myself using it a lot more in the future. Any idea when 2.0 will be out of beta? I watched the demo and the new control panel looks fantastic.

Dec 15, 2010 at 8:06 PM

I may  need to create a new post for this, if so let me know. But I just noticed that once I approve a post, all future posts seem to be automatically approved. Not sure if thats because I am on the same IP address or what. I do have my comment settings to manual. Is there a way to force it to require EVERY post to be approved before showing up?

Thanks

Coordinator
Dec 15, 2010 at 8:11 PM

That's very good news it's working.  The final BE 2.0 might be out the last week of December ... unless we run into any issues, then January.

I see this Interlude theme here.  The one there is running on BE 1.5.  It could be that it has problems under 1.6.1.  Since this theme has been around a while, I don't think it's targeted specifically at BE 2.0 ... it was probably created during the BE 1.5 days.  Plus, if it was targeted at BE 2.0, it wouldn't explicitly add Syntax Highlighter code since that is already included in BE 2.0, as an extension.  So, basically, it's an older theme, I think.

Speaking of the syntax highlighter, someone else had a problem with Syntax Highlighter conflicting with a jQuery based Lightbox he is using (but only in IE).  Not directly related to what you ran into, but just wondering if maybe Syntax Highlighter doesn't always work nicely with other plugins or existing setups.  Could just be a coincidence too.

Coordinator
Dec 15, 2010 at 8:15 PM

When you say force every "post" to be approved ... you mean force every "comment" to be approved, right?

First of all, by default, I believe if you are logged into the blog, your comments will automatically be approved.

For logged out people, in BE 1.6.1 if you go into the control panel, go to Comments, and then click on the "Configuration" tab on the right hand side.  Once there, for Moderation, select "Manual".  By doing this, every comment will need to be explicitly approved before it will appear.

Dec 15, 2010 at 8:17 PM

Yes you are right. I am getting tired I guess. Been looking at this code too much today.

Yes, I meant "comment" not "post", and yes I am an idiot.
I was just coming back to say I realized I was logged in while making the other comments, so thats why they were automatically approved.

I tested it not logged in and I realized that the comments were doing as they should, awaiting for moderation.

Thanks again.

Apr 17, 2014 at 8:34 PM
I found the solution (for me) changing the addLoadEvent function:
addLoadEvent: function (func) {

        if (window.addEventListener) // W3C standard
        {
            window.addEventListener('load', func, false); // NB **not** 'onload'
        }
        else if (window.attachEvent) // Microsoft
        {
            window.attachEvent('onload', func);
        }
}