Question

i'm new to asp.net and busy with a tutorial website.

I'm trying to call a server side function using an if statement, the problem is that the if statement is completely ignored i.e the function is called regardless.

This works when using a normal js alert

code below:

$(function () {
    $("#idnum").keyup(function () {
        if (this.value.length == 13) { 
            <%= TextBox1_TextChanged(this, idnum.Text) %> ; 
            //call code behind function to get contact info with ID
        }
    });
});
Was it helpful?

Solution

You can't invoke server side methods on client with your code. Try to use PageMethods in order to call server side method from client.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top