I am trying to use a confirm message box in c# either in javascript or the Ajax ConfirmButtonExtender based on an error number returned from SQL passed to a variable. for instance, if my SQL returns 1 for int ErrorNumber = 1 then I want to ask whether the user would like some text inserted in SQL. If Yes then I will pass the text to be entered.
Sorry I have no code example, but everything I have tried does not work as expected.
Any suggestions would be welcome.
Update I have a workaround although not what I was trying to achieve.
<script type = "text/javascript">
function Confirm_System() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to add the System?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>
when the button on my webpage is pressed I then get the result back from the popup Confirm box
protected void c_AddText_Click(object sender, EventArgs e)
{
string confirmValue = Request.Form["confirm_value"];
if (confirmValue == "Yes")
{
//do something
}
}
I have added OnClientClick to point to my Javascript function
OnClientClick = "Confirm_System()"
If anyone knows how to do this without the need to have a button on the webpage so it fires when an error number comes back from my SQL Stored Proc then I would be grateful.