I am not able to pass a value from Javascript to code behind. The result value is always undefined.
I have attached the code:
<input id="Button2" type="button" value="FunctionCall" onclick="CallingServerSideFunction()" />
<script type="text/javascript">
function CallingServerSideFunction() {
alert("start");
var result =PageMethods.Add(1,2);
alert(result);
}
</script>
</form>
My cs code: public static int Add(int x, int y)
{
int k = x + y;
return k;
}
Help me out with this!