Click here to Skip to main content
15,887,975 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,

My facebook javascript will work if i uses html hyperlink onclick="postSomething()

But how can i call this "postsomething()" function in my LinkButton?

<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="postSomething()">LinkButton


I'm trying to session the Text output once i click this linkbutton.

Thanks for your help!

Yours,
Aaron
Posted

1 solution

You have to call like below :

<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="return postSomething();">LinkButton</asp:LinkButton>



For more info check this :

http://stackoverflow.com/questions/1672235/call-javascript-from-link-button[^]

I hope this will help to you.
 
Share this answer
 
v2
Comments
Member 10106656 22-Jul-13 1:13am    
Thanks for your help! But the OnClientClick return null.

I think its i'm using the Facebook API/Javascript placed in the body, but not in the head.
It works on HTML hyperlinks onclick~ Pls help!
Sampath Lokuge 22-Jul-13 9:04am    
Can you put the code for "postsomething()" function and the way you placed above function inside the <script> tags ? Is this function is in master file or somewhere else ?
Member 10106656 22-Jul-13 14:21pm    
<script type="text/javascript">
var name;
function postSomething() {
FB.api('/me', function (response) {
function setLabelText(ID, Text) {
document.getElementById(ID).innerHTML = Text;
name = response.name;
alert(name);
}
setLabelText("Label1", response.name);


});
}


</script>

Hi this are the codes, the function is in the head.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900