jeudi 13 août 2015

Asp.net Call Code Behind with JavaScript

since i didn´t find any solution that helped me, i thought i asked. I need a JavaScriptfunction with calls a method in my code-behind, and since i´m really new to this, i dont understand what am i doing wrong. On my Master Page (Site.Master) i enabled PageMethods:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />

And in the Content of my Page i have put the Script:

        function reply_click(clicked_id) {
            alert(clicked_id);
            PageMethods.javascriptTest(clicked_id);

And now my method in the code-behind:

    [WebMethod]
    public void javascriptTest(int buttonID)
    {

        Test2.Text += buttonID + "***";

        // Use the ID for DB access

    }

I need that ID for later, when i have to do stuff in my database, but i´m always getting PageMethods undefined errors and i dont know why :/



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire