When trying to implement the Google Plus One button using AddThis on one of our localized pages, we encountered a strange issue. Despite retrieving data from the backend (let's assume a database), the plus button was not loading during an AJAX based partial postback.
The following HTML snippet is dynamically added to the page only during a partial postback:
<div class="addthis_toolbox addthis_default_style" style="float:right;">
<a class="addthis_button_google_plusone" g:plusone:size="small"></a>
</div>
Simultaneously, the script is included through:
ScriptManager.RegisterStartupScript(Page, typeof(string),
"RegisterHTMLScript" + scriptID,
scriptstring,
false);
The value of scriptstring is as follows:
<script type="text/javascript">
var addthis_config = {"data_track_clickback":true};
if (window.addthis) {
addthis.toolbox('.addthis_toolbox');
addthis.init();
}
else {
$.getScript('http://s7.addthis.com/js/250/addthis_widget.js#username=XXXXX&domready=1');
$.getScript('https://apis.google.com/js/plusone.js');
}
</script>
No client-side errors are visible, yet the +1 button remains invisible. What could be causing this issue?
I attempted the following instead of RegisterStartupScript: 1. Adding ScriptReference programmatically to the current ScriptManager. 2. Using the RegisterClientScriptInclude method on the ScriptManager.
However, I achieved almost the same result.