the solution1 is good and here I explain to you how to add to your code behind a page method and use it in javascript:
here is your code behind:
[WebMethod]
[ScriptMethod]
public static int getSqlCountAjax()
{
}
then use script manager and enable pagemethod property:
function validateLink() {
PageMethods.getSqlCountAjax(onRequestComplete, onError);
function onRequestComplete(result) {
var sqlCount = result;
if (sqlCount > 15) {
return true;
} else if (sqlCount >= 10 || sqlCount <= 15) {
if (confirm('yr confirmation mesaage here...') == 1) {
return true;
}
} else {
alert('not allowed to navigate to this page');
return false;
}
return false;
}
}