Mario
Mario

Reputation: 14760

ASP.NET MasterPage javascript error

I have this javascript:

<script type="text/javascript">
            $(document).ready(function () {
                $('#social-share').dcSocialShare({
                    buttons: 'twitter,facebook,linkedin,digg,stumbleupon,delicious,pinterest,buffer,print,email',
                    offsetLocation: 0,
                    center: 625,
                    floater: false
                });
                var a = $('#dcssb-1');
                buttonPosition(a);
                $(window).scroll(function () {
                    buttonPosition(a);
                });
            });
            function buttonPosition(obj) {
                var top = $(document).scrollTop();
                var p = top > 400 ? { marginTop: '20px' } : { marginTop: (400 - top) + 'px' };
                obj.css(p);
            }
</script>

When I place the code in MasterPage or in a Page which uses a Masterpage I get this error:

Object doesn't support property or method 'dcSocialShare' 

I have placed all the JS includes correctly in the the page, but when I use it without a materpage it works, why I get this error only when it's placed in the masterpage or in a page which uses a masterpage?

Upvotes: 0

Views: 333

Answers (1)

Talha
Talha

Reputation: 19252

try to include your js files in asp:ScriptManager like the following

<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Scripts>
        <asp:ScriptReference Path="~/jquery.js" />
    </Scripts>
</asp:ScriptManager>

Upvotes: 1

Related Questions