0

Please Help me, I want to call a server side function in page1 from page2 using java script.

For example in Home.aspx.cs i have read() webmethod and i want to call this method from Call.aspx's Javascript function.

5
  • Why not place the webmethod code in a separate webservice? Commented Feb 2, 2016 at 7:27
  • You need to use ajax Commented Feb 2, 2016 at 7:29
  • Hi Mr.White my aim is to call the server side method from javascript. so i feel a separate web service is not needed Commented Feb 2, 2016 at 7:31
  • Hi Erikscandola, am using javascript but i am receiving the error "read() method is unidentified" Commented Feb 2, 2016 at 7:33
  • call.aspx i am using the below code. <script type="text/javascript"> function HandleOnclose(e) { debugger; //alert(userid); var clickY = window.event.clientX; var altKey = window.event.clientY < 0; if (clickY>0 && altKey==true) PageMethods.UpdateUserLogoutStatus(); } window.onbeforeunload = HandleOnclose; </script> in Home.aspx.cs [WebMethod] public static void UpdateUserLogoutStatus() { Commented Feb 2, 2016 at 7:35

1 Answer 1

1

You need to create an ajax call:

$.ajax({
    url: "linkToOtherPage",
    method: "POST", // or GET, I don't know what you need
    data: dataToPass,
    success: function (response) { },
    error: function(jqXHR, textStatus, errorThrown) { }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.