【发布时间】:2011-12-19 17:07:05
【问题描述】:
我想先显示警报,然后显示确认框。 仅当树视图包含子节点时才应显示警报。
到目前为止,这是我的代码,代码先显示确认框,然后显示警报。有什么方法可以切换它们,以便在确认之前显示警报?
//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?');");
}
//显示警告信息
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);
}
}
谢谢
更多细节:
我在网页上有一个树形视图和一个删除按钮。 树视图加载父节点和子节点。 如果我在选择带有子节点的父节点后单击删除,它应该给我一个警报,然后是一个确认框。如果我选择子节点或没有任何子节点的父节点,那么它应该只显示确认框。
【问题讨论】:
-
如果您想回答您的问题,您可能需要提供更多信息。我觉得这太模糊了,无法掌握你在做什么。尝试提供一个概述,并解释第一段代码是什么。
-
将你的 typeof(string) 更改为 this.GetType() 按照下面的示例进行操作.. 对我有用.. 让我知道它是否有效
-
@ArmedMonkey 我在解释中添加了详细信息,如果您需要更多详细信息,请告诉我