try Like this
place this Javascript on aspx page
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you Want to View DashBoard?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
Place Button/ImageButton
<asp:imagebutton id="btnSwitch2" runat="server" xmlns:asp="#unknown">
ImageUrl="~/Images/dptch.jpg" OnClick="OnConfirm"
OnClientClick="javascript:Confirm();" style="width: 20px" Width="20px"
Height="21px" ImageAlign="AbsMiddle" Visible="False" />
</asp:imagebutton>
in code behind
Protected Sub OnConfirm(ByVal sender As Object, ByVal e As EventArgs)
Dim confirmValue As String = Request.Form("confirm_value")
If confirmValue = "Yes" Then
---Do what you want when Yes
Else
---Do what you want when No
End If
End Sub
is in vb.net but you can convert to C# here
http://www.developerfusion.com/tools/convert/csharp-to-vb/[
^]
IN c# here
protected void OnConfirm(object sender, EventArgs e)
{
string confirmValue = Request.Form("confirm_value");
if (confirmValue == "Yes") {
----Do what You want when Yes
}
else {
----Do what You want when No
}
}