You must Sign In to post a response.
  • Category: ASP.Net MVC

    I got a requirement that is sharing article on facebook

    Hii All,
    i want to share my article on Facebook, i am using Asp.net Mvc
    i have done this task , but getting issue by default some content from bottom menu is showing in dialog share window for every article
    suggest me how to fix this one
  • #764541
    You can use given code snippet in your program to share your articles of Facebook by using Asp.net Mvc

    using System.Web.UI.HtmlControls;
    protected void Page_Load(object sender, EventArgs e)
    {
    lblShare.Text = "<a name=\"fb_share\" type=\"button\"></a>" +
    "<script " +
    "src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" " +
    "type=\"text/javascript\"></script>";
    HtmlMeta tag = new HtmlMeta();
    tag.Name = "title";
    tag.Content = "This is the page title";
    Page.Header.Controls.Add(tag);
    HtmlMeta tag1 = new HtmlMeta();
    tag.Name = "description";
    tag.Content = "This is a page description.";
    Page.Header.Controls.Add(tag1);
    }


    More details at given URL
    http://www.c-sharpcorner.com/uploadfile/raj1979/how-to-use-facebook-share-functionality-in-Asp-Net/
    http://forums.asp.net/t/2006581.aspx?Using+facebook+share+button+in+mvc

  • #764547
    without looking at your code it is difficult to manage the things, can you post your code so that we can help you better.
    As far as I know it is very easy to share something on facebook, just you need to pass your url as a query string named u and facebook render that url content data and link for sharing.
    see below sample
    <a href="http://www.facebook.com/sharer.php?u=http://share path of your html file" title="share on facebook">Click to share on facebook</a>
    or you can switch to below link for more information
    http://www.c-sharpcorner.com/UploadFile/75a48f/implement-facebook-comment-like-share-in-your-asp-net-web/

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764578
    i used below code for Sharing
    var fburl = "http://www.facebook.com/share.php?u=";
    strpostinfo = strpostinfo + '<a class="btn btn-primary btn-xs" href=' + totUrl + ' onclick="return fbs_click(600, 600)" target="_blank" title=""><i class="fa fa-facebook"></i>Share</a>';
    strpostinfo = strpostinfo + '</div></div>';
    //End for Share Info into Socialsites
    $('#Blogtypedata').empty();
    $('#Blogtypedata').append(strpostinfo);
    function fbs_click(width, height) {

    var leftPosition, topPosition;
    leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
    topPosition = (window.screen.height / 2) - ((height / 2) + 50);
    var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
    // u = location.href;
    t = document.title;
    u = 'https://medintu.com/beta/Blogs/MorePostInfo/14/-Nutritious-Fiber-Rich-Diet';
    window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', windowFeatures);
    return false;
    }


Sign In to post your comments