在VS2005中将confim框输入到C#变量

在VS2005中将confim框输入到C#变量,c#,javascript,visual-studio-2005,C#,Javascript,Visual Studio 2005,如何使用asp.net中的确认框从用户处获取输入,并将输入存储在C#变量中。 无论是“确定”还是“取消”按钮。请帮我向前走 比如我用这样的, 回答。写下(“确认(‘已存在的测试文件是否替换?)”) 相反,我需要c#variable中确认框的输出…尝试以下操作: 您的javascript函数: <script type="text/javascript" language="javascript"> function ConfirmOnReplace() { i

如何使用asp.net中的确认框从用户处获取输入,并将输入存储在C#变量中。 无论是“确定”还是“取消”按钮。请帮我向前走

比如我用这样的, 回答。写下(“确认(‘已存在的测试文件是否替换?)”)

相反,我需要c#variable中确认框的输出…

尝试以下操作:

您的javascript函数:

<script type="text/javascript" language="javascript">
    function ConfirmOnReplace() {
        if (confirm("Are you sure?") == true)
            return true;
        else
            return false;
    }
</script>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return ConfirmOnReplace();" />
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Click += new EventHandler(Button1_Click);
    }

    void Button1_Click(object sender, EventArgs e)
    {
        // If you are here, your javascript method returned true
        // TODO: Replace the file, or do what you want
    }
}