I was wondering if there is a way to capture the yes/no values on the server side once the y/n buttons are clicked on a javascript pop up?
I am displaying the y/n pop up while using a dropdown menu but pretty much all the solutions i have seen so far use button's onClick event.
By reading Mudassar's article:
http://www.aspsnippets.com/Articles/ASPNet-Server-Side-Yes-No-Confirmation-Box-using-JavaScript.aspx
I am able to see the pop up box with the yes/no options but after i click a 'yes' or 'no', i don't see 'You clicked Yes' or 'You clicked No'.
This is the code i have so far which has been taken from Muddassar's article that uses a button, not a drop down.
I can see for button the "Confirm()" is being called by OnClientClick event, but i haven't been able to make it to work in a dropdown.
Any help will be appreciated,
Thank you.
************************
On the aspx page:
<asp:DropDownList ID="ddlWorkBucket" runat="server" AutoPostBack="true" DataSourceID="SqlDataSource8" DataTextField="workBucketName" DataValueField="workBucketID" Width="120px" onChange="Confirm()" OnSelectedIndexChanged="OnConfirm"></asp:DropDownList>
Also on the same aspx page is this javascript function:
<script language ="javascript" type="text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to change time category?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>
This is what i have on the code behind file:
In page load:
ddlWorkBucket.Attributes.Add("onChange", "return Confirm();")
And then also on the code behind page (not in page load):
Protected Sub OnConfirm(ByVal sender As Object, ByVal e As EventArgs)
Dim confirmValue As String = Request.Form("confirm_value")
If confirmValue = "Yes" Then
ClientScript.RegisterStartupScript(Me.[GetType](), "alert", "alert('You clicked YES!')", True)
Else
ClientScript.RegisterStartupScript(Me.[GetType](), "alert", "alert('You clicked NO!')", True)
End If
End Sub
*******************************