Solved

AddThis.com Social Buttons After Update Panel Postback

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

815 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

11 Experts available now in Live!

Get 1:1 Help Now