User1814019480 posted
Hi Robby,
Thanks for your posting.
Base on my experience, I think we can take those action to debug and resolve this issue.
The first one:
Could you try to add the breakpoint on your JS and server side code to test which steps toke long time caused the delay? I afraid that the script manager need time to load the JS file and script into the memory to call the server side function.
So the second action is that I suggest you can change your code as the JQuery Ajax or xmlHttprequest to call the server side function.
I recommend you refer to this demo:
using JQuery:
http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js
JS Code:
<script type="text/javascript">
//Called this method on any button click event for Testing
function MyFunction(Param1, Param2) {
$.ajax({
type: "POST",
url: "MyPage.aspx/MyMethod",
data: "{ Param1: '" + Param1+ "',Param2: '" + Param2 + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: "true",
cache: "false",
success: function (msg) {
// On success
},
Error: function (x, e) {
// On Error
}
});
}
</script>
Code behind Code:
using System.Web.Services;
[WebMethod]
public static void MyMethod(string Param1, string Param2)
{
try
{
//Do here server event
}
catch (Exception)
{
throw;
}
}
Also, you can use this method to call the code behind function:
function loadServerData() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("demo").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "mypage.aspx/mymethod", true);
xhttp.send();
}
Please try it.
Any concerns, please feel free to let me know.
Regards,
Will