Solved

AddThis.com Social Buttons After Update Panel Postback

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Finding the IIS version 5 21
return false must be hit after calling certain command 10 32
Filktering Alphabetically 8 29
what is the best Integrated development environment 2 20
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

809 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