Solved

AddThis.com Social Buttons After Update Panel Postback

Posted on 2014-09-05
2
326 Views
Last Modified: 2014-09-22
Hi,

I am having issues keeping the AddThis Buttons live after a postback.

        Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
        sb.Append("<script type=""text/javascript"" src=""//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4d7531fa1e1f4be5""></script>")

        If (Not ClientScript.IsStartupScriptRegistered("SocialJava")) Then
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "SocialJava", sb.ToString(), False)
        End If

Open in new window


I can fire it after the load and it will work once or on load and it will work once, but never a second time.

I have tried lots of solutions to get it working, but i'm running into issues as its an external file?

Any help would be appreciated?

Cheers
Karl
0
Comment
Question by:Karl Blackburn
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40307130
check this page : http://www.addthis.com/blog/2013/05/07/a-brief-history-of-using-addthis-dynamically/#.VAp0imR5Odw

so put the following in head section : <script src="http://s7.addthis.com/js/300/addthis_widget.js#async=1" type="text/javascript">

and use :
        Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
        sb.Append("<script type=""text/javascript"">window.onload = function() { addthis.init(); }</script>")

        If (Not ClientScript.IsStartupScriptRegistered("SocialJava")) Then
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "SocialJava", sb.ToString(), False)
        End If

Open in new window

0
 

Author Comment

by:Karl Blackburn
ID: 40308637
Hi,

I looked through this article previously, but your example really helps.

Unfortunately it still won't fire on either load or postback unless I use my url -

"//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4d75gfhdgfhdgfh"

but then this again won't fire on postback.

Anything spring to mind?

Cheers
Karl
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now