I am having a page where i need to confirm whether to show updated grid or not
I am calling a javascript function using
ScriptManager.RegisterStartupScript(this, typeof(string), "Error", "confirm('Are u sure');", true);
What I want to know is how to get the return value of confirm in C# code behind.
Instead of this
ScriptManager.RegisterStartupScript(this, typeof(string), "Error", "confirm('Are u sure');", true);
use this
ScriptManager.RegisterStartupScript(this, typeof(string), "Error", "ConfirmUser('Are u sure');", true);
<script type='javascript'>
function ConfirmUser(msg)
{
if(confirm(msg))
__doPostBack('','');
}
<script>
see following links to know more about __doPostBack
I am having a page where i need to confirm whether to show updated grid or not
You may prevent the postback when use choose Cancel
button of confirm dialog.
<asp:Button ID="Button1" runat="server"
OnClientClick="return confirm('Are you sure to populate the list?');"
Text="Button" onclick="Button1_Click" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.