Here you have to use jQuery Ajax for retrieve the data from the DB, when you click the button.After that load your popups according to the true/false situation.
I hope you're using ASP.net web forms: (sample code snippet)
<script type="text/javascript">
function getSentence() {
$.ajax(
{
url: "default.aspx",
data: "get=sentence",
success: function (data)
{ $("#txtSentence").get(0).value = data; },
error: function () { alert(arguments[2]); }
});
}
</script>
Please check this link for more info :
AJAX basics with jQuery in ASP.NET