简体   繁体   English

确认前显示提醒

[英]Show alert before confirmation

I want to display an alert first and then show the confirmation box. 我想先显示一个警报,然后显示确认框。 The alert should only be displayed if the treeview contains childnodes. 仅在树视图包含子节点时才显示警报。

Here is my code so far, the code shows confirmation box first and then alert. 到目前为止,这是我的代码,该代码先显示确认框,然后发出警报。 Is there any way to switch them around so the alert is shown before confirmation? 有什么办法可以切换它们,以便在确认之前显示警报?

//shows the confirmation box
    if (!Page.IsPostBack)
                {              
                        btn_save_delete.Attributes.Add("onclick", "return confirm('Deleting the Selected Item will also delete any existing Children under it! Confirm Changes?');");
                   }

//shows the alert message //显示警报消息

protected void btn_save_delete_Click(object sender, EventArgs e)
        {

            if (tree_items.SelectedNode.ChildNodes.Count >= 1)
            {
                ScriptManager.RegisterStartupScript(this.tree_items, typeof(string), "Alert", "alert('Message here');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.tree_items, typeof(string), "Alert", "alert('Message here2');", true);
            }
}

Thank you 谢谢

Further detail: 更多细节:

I have a tree view and a delete button on the webpage. 我在网页上有一个树形视图和一个删除按钮。 The tree view loads with parent nodes and child nodes. 树视图将加载父节点和子节点。 If I click on delete after selecting a parent node with child nodes, it should give me an alert and then a confirmation box. 如果在选择带有子节点的父节点后单击删除,它将给我一个警报,然后是一个确认框。 If I select a child node or a parent node without any child nodes then it should only show me the confirmation box. 如果我选择一个子节点或一个没有任何子节点的父节点,那么它应该只显示确认框。

why not try to format your Alert..try this you will need to change the Alert message to fit your example...//strExport is what you will assign your alert message.. 为什么不尝试格式化您的Alert..try,您需要更改Alert消息以适合您的示例... // strExport是您将分配警报消息的内容。

string script = "alert('" + strExport + "');";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true); 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM