Calling a c# function from a Javascript method

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Im trying to call a c# function from a javascript function:

In my default.aspx I have following code: (javascript)<script type="text/javascript

function App() {
var temp;
temp = PageMethods.Connect();
alert(temp);
}
</script>

(HTML)<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent
<div class="menuContent
#" onclick="App(); blabla!
<div id="navTreeContainer
<div id="navtree


</asp:Content>

Default.aspx.cs[WebMethod]
public static string Connect()
{
string test;
test = "test";
return test;
}When I try this out nothing happens.
I dont know what I do wrong here...
Someone that can help me please ?
Thanks!


View the full article
 
Back
Top