Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7712377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:36:55+00:00 2026-06-01T01:36:55+00:00

I want to call my facebook send dialog function from code behind : The

  • 0

I want to call my facebook send dialog function from code behind :

The javascript code is :

function facebook_send_message(to) {
    FB.ui({
        app_id:'*****',
        method: 'send',
        name: "*****",
        link: '*****',
       to: <%=to %>,
        description:'sdf sdf sfddsfdd s d  fsf s ',
        redirect_uri: '******'


    });
}

The twist here is i want to call this from a dynamically generated Aspx button

 Button btn = new Button();
 btn.CssClass = "btn-add";
 btn.Text = "Invite";
 btn.Click += new EventHandler(btn_Click);

I tried this code on the button click

protected void btn_Click(object sender,EventArgs e)
{

    Page.ClientScript.RegisterStartupScript(Page.GetType(), "my", "function facebook_send_message(to);", true);

}

However it is not working Please help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:36:56+00:00Added an answer on June 1, 2026 at 1:36 am

    Add it as an attribute.

    btn.attributes.add("OnClientClick", "javaScript: return myfunction(););
    

    If OnClientClick doesnt work, try onClick. Cant remember from top of my head which one will work.

    Make sure to return false from the JS function to prevent Postback.

    Pseudo code:

    –JS Function–

    function myFunction() {
             alert('this is my fb function');
             return false;
    }
    

    –Adding button in aspx.cs page–

    Button b = new Button();
    b.ID = "btnSomeButton";
    b.Text = "Call fb button";
    dvButton.Controls.Add(b);
    b.Attributes.Add("onclick", "return myFunction();");
    

    You dont need btn_click event as you have in your code. You also dont need RegisterStartupScript as you already have your function in JS file. RegisterStartupScript is used when you want to add JS function to the page from the server side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call a c# function from my javascript function. I have a
I want to call a function from a .NET DLL (coded in C#) from
I want to call my .NET code from unmanaged C++. My process entrypoint is
I want to call some RESTful web services from a J2ME client running on
I want to call an ASHX file and pass some query string variables from
I want to call a function (which calculates my version number) when my NSIS
I am just getting started with the Facebook JavaScript SDK, all I want to
I want to be able to post on users Twitter feed from a Facebook
I am trying to hack a little this facebook javascript code to make a
Facebook has a special javascript call for setting Fanpage permissions. Unfortunately, I can't get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.