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?
Add it as an attribute.
If
OnClientClickdoesnt work, tryonClick. Cant remember from top of my head which one will work.Make sure to
return falsefrom the JS function to preventPostback.Pseudo code:
–JS Function–
–Adding button in aspx.cs page–
You dont need
btn_clickevent as you have in your code. You also dont needRegisterStartupScriptas you already have your function in JS file.RegisterStartupScriptis used when you want to add JS function to the page from the server side.