You can call an instance method with Javascript like following.
<script>
function CodeBehindMethod(var conditionValue) {
if(conditionValue==true)
alert('<%= GetFirstValue() %>');
else
alert('<%= GetSecondValue() %>');
}
</script>
Code Behind will look like --
public String GetFirstValue()
{
return "FirstValue";
}
public String GetSecondValue()
{
return "SecondValue";
}
In case, I am wrong somewhere, please let me know :)