0

For this following code:

 var idArray = ["10","20","30"];

        $.each(idArray, function(i, value){
            if(<%= GeneralHelper.GetItemUrlByItemId(value)%>){ //I cannot use the variable value
                alert('record found');
        }
        });

Code for my class:

public sealed class HelperClass{

 public static bool HelperFunction(string Id){

 // check some data in database against the id

 // return true if record found  

}

}
Kamran
  • 4,010
  • 14
  • 60
  • 112

1 Answers1

0

The problem:

  • Server-side code is evaluated on the server, before anything is transmitted to the client.

    • Client side code (JavaScript) is evaluated in the browser, after the server has finished transmitting the document. After understanding the above statements, you'll see that your current example is technically impossible.

What you will need to do (if your goal is to prevent a page refresh) is send the new data to a script on the server using AJAX. The script will process the data and respond to the browser.

fdfey
  • 587
  • 2
  • 11