Getting device filters, add this and .net to work together
An issue I’ve come across a few times when adding an Add This button to any .net application is that the following error message is thrown:
The string 'fb:like:layout' contains too many device filters. There can be only one.
There’s something about the Highlander with that one, and it’s a bit irritating to say the least, but the fix is a simple one.
All you need to do is to enter the required Add This code without the device filters, and then add them with javascript (I use jQuery here):
<div class="addMe">
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox">
<a class="addthis_button_facebook_like"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
</div>
<script type="text/javascript">
jQuery('.addthis_button_facebook_like').attr('fb:like:layout',
'button_count');
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/
addthis_widget.js#username=xxx"></script>
<!-- AddThis Button END -->
I’m not quite sure why .net throws this error, and it’s a shame that javascript is required to fix it, but for now it’ll do.
8 Responses
Just an FYI, a non-JS fix I just did for a client with the same problem is to just surround the fb:like:layout like so:
<a class="addthis_button_facebook_like" =”button_count”>…
The output sent to the browser is exactly the same, but the parser won’t get choked up on the colons.
Sorry, it didn’t take all the characters in that. It should be: less-than-sign %=”fb:like:layout”% greater-than-sign.
I prefer to use server side code in the code-behind.
so:
then in code behind:
hypFacebookLike.Attributes.Add(“fb:like:layout”, “button_count”);
Absolutely fantastic fix, both server side and javascripts.
add this buttons are easier to plugin, but because of the facebook error i don’t use them.
from now i can use it.
thanks a lot
Brilliant! A life saver
Thanks,
Perfect fix.
Excellent Fix. You have my eternal gratitude
This worked for us:
<a class="addthis_button_facebook_like" >