Solved

AddThis.com Social Buttons After Update Panel Postback

Posted on 2014-09-05
2
329 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

911 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

17 Experts available now in Live!

Get 1:1 Help Now