asp.net - asp.net 中服务器端的确认框

标签 asp.net alert server-side serverside-javascript confirmation

我想从服务器端在 asp.net 中显示确认框:

我想从服务器端调用它,因为我必须从服务器端获取客户消息。我正在使用下面的代码

    string str = "Are you sure, you want to Approve this Record?";
        ClientScript.RegisterStartupScript(typeof(Page), "Popup", "return confirm('" + str + "');",true);
// More code ....

现在它显示弹出窗口,无论我点击什么,无论是“确定”还是“取消”,我的代码都在执行。

请告诉我当用户在确认框中选择“取消”时如何限制代码执行。

最佳答案

检查一下:

代码隐藏:

string str = "Are you sure, you want to Approve this Record?";
        this.ClientScript.RegisterStartupScript(typeof(Page), "Popup", "ConfirmApproval('" + str + "');", true);

ASPX:

function ConfirmApproval(objMsg)
    {
        if(confirm(objMsg))
        {
            alert("execute code.");
            return true;
        }    
        else
            return false;    
    }

关于asp.net - asp.net 中服务器端的确认框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5114607/

相关文章:

asp.net - 什么是 ASP.NET 中的 gpstate 文件

c - 如何最好地部署用 C 编写的 Web 应用程序?

asp.net - ASP.NET服务器端和客户端将值从一个页面传递到另一个页面有多少种方式

jquery - 如何在 ASP.NET 内容表单中使用 JQuery 验证

asp.net - 需要粘性 session 的负载平衡 Web 的正确设置?

c# - 通过javascript保存对话框

javascript - 如何停止多个警报中的 JavaScript?

javascript - 使用 jQuery jqXHR responseText 在警报窗口中换行

javascript - mailto链接添加JS提醒

jquery - 服务器端模板、客户端模板 - 自动转换?