简体   繁体   English

如何处理是否单击按钮时使用Javascript弹出的对话框

[英]How to handle Yes No dialog that was pop-up using Javascript on button click

I am having an update button on my from on clicking update i would like to prompt the user as Do you want to delimit the record with Yes and No buttons. 我单击“更新”后就出现了更新按钮,我想提示用户,是否要使用“是”和“否”来定界记录。 If the user clicks on Yes i would like to execute the code which can delimit the record if not just update the record. 如果用户单击“是”,我想执行可以分隔记录的代码,如果不只是更新记录的话。

My sample code 我的示例代码

protected void btnUpdate1_Click(object sender, EventArgs e)
{
    EmpID = Convert.ToInt32(HiddenField1.Value);

    if (ID == 2)
    {
        oEmployeePersonalData.EmpID = EmpID;
        oEmployeePersonalData.PhoneNumberTypeID = ddlPhoneType.SelectedValue;
        oEmployeePersonalData.PhoneNumber = Convert.ToInt64(txtph1.Text);
        oEmployeePersonalData.EndDate = DateTime.Today.AddDays(-1);

//As per my requirement if i click on yes i would like to execute this code //根据我的要求,如果我单击是,我想执行此代码

        if (oEmployeePersonalData.PhoneDetailUpdate())
        {
        }

// If No different code //如果没有其他代码

if(confirm("Would you like to delimit the record"))
{
    //Delimit record code or return true;
}
else
{
    return false;
}
var ans = confirm("Do you want to delimit the record?")
if (ans){
    //clicked on yes        
}
else{
     return false;  
}

Add following javascript function in the header of the page 在页面标题中添加以下javascript函数

 <script type="text/javascript">
        function update() {
            var result = confirm("Do you want to delimit the record?")
            if (result) {

            }
            else {
                return false;
            }


        }

    </script>

and then attach the event to button 然后将事件附加到按钮

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击按钮可打开弹出窗口的Javascript代码? - Javascript code to open pop-up window on button click? 如何使用 C# 处理 Outlook 中的安全弹出窗口 - How to handle security pop-up in outlook using C# 如何在不单击任何按钮并获得用户响应的情况下显示C#代码后面带有“是”和“否”选项的弹出窗口 - How to display Pop-up with Yes and No option from C# code behind without clicking any button and taking response from user (ASP.NET)如何执行此操作:在GridView中单击按钮以打开包含另一个Gridview的弹出窗口 - (ASP.NET) How to do this: Button click in GridView to open pop-up window containing another Gridview 如何在UpdatePanel中单击按钮后如何在UpdatePanel内部的弹出窗口中填充GridView - How to populate a GridView in a pop-up that is inside an UpdatePanel after a button click inside an UpdatePanel 单击弹出窗口中的按钮后,如何刷新上一页? - How to make previous page refresh after I click a button in pop-up window? 如何使button_Click事件在ASP.NET的弹出窗口中打开页面? - How to make the button_Click event opens the page in a pop-up window in ASP.NET? 如何在WPF中从弹出对话框窗口导航到另一个页面我未使用MVVM - How to navigate from a pop-up dialog window to another page in wpf i'm not using MVVM 如何在WCF通话中显示对话框/弹出窗口? - How to show dialog/pop-up on wcf call? 如何制作一个不会停止程序执行的弹出对话框? - How to make a pop-up dialog that does not stop the program execution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM