簡體   English   中英

在VS2005中獲取confim框到C#變量的輸入

[英]Getting the input of a confim box to C# variable in VS2005

如何使用asp.net中的確認框從用戶獲取輸入並將輸入存儲在C#變量中。 無論是好還是取消按鈕。 請幫助我前進。

例如,我正在使用這樣的Response.Write(“確認('測試FiileAlready現有替換嗎?')”);

相反,我需要c#變量中的確認框的輸出...

嘗試這個:

你的javascript函數:

<script type="text/javascript" language="javascript">
    function ConfirmOnReplace() {
        if (confirm("Are you sure?") == true)
            return true;
        else
            return false;
    }
</script>

ASP.NET按鈕:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return ConfirmOnReplace();" />

代碼隱藏(YourPage.aspx.cs)文件:

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
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM