动态添加按钮省略确认
Dynamically added button omits confirm
我正在为我动态添加控件的用户开发一个网站。
问题是,在出现 confirmBox 之后,无论我点击什么 (Ok/Cancel),它仍然会删除我的对象。
这就是我从 codeBehind 添加它们的方式:
aPanel.RegisterAction("DeleteStuff", "Delete object",
true, btnDeleteClick, null);
其中 aPanel 是 ActionPanelDx
紧随其后:
if (actionPanel["DeleteStuff"] != null)
actionPanel["DeleteStuff"].ClientSideEvents.ItemClick =
"function(s,e){return confirm('Are you sure you want to delete?')}";
protected void btnDelete_Click(object sender, MenuItemEventArgs e)
{
//Im using self written classes for handlig SQL logic it looks like this:
MySQLCommand commad = new MySQLCommand("delete_object");//procedure
commad.MyParam.AddWithValue("@ob_id", ObjectID);
commad.myExecuteNonQuery();
}
我是不是用错了JS函数?
现在,只要单击一个按钮(无论哪个按钮),您的代码都会删除您的对象。你需要做的是这样的:
protected void btnDelete_Click(object sender, MenuItemEventArgs e)
{
if (e.item.name === "Yes")
{
MySQLCommand commad = new MySQLCommand("delete_object");//procedure
commad.MyParam.AddWithValue("@ob_id", ObjectID);
commad.myExecuteNonQuery();
}
}
而不是 e.item.name
它可能是 e.item.text
或类似的东西,放置一个断点或 console.log
看看你的 e
属性 如果你不确定。
我正在为我动态添加控件的用户开发一个网站。
问题是,在出现 confirmBox 之后,无论我点击什么 (Ok/Cancel),它仍然会删除我的对象。
这就是我从 codeBehind 添加它们的方式:
aPanel.RegisterAction("DeleteStuff", "Delete object",
true, btnDeleteClick, null);
其中 aPanel 是 ActionPanelDx
紧随其后:
if (actionPanel["DeleteStuff"] != null)
actionPanel["DeleteStuff"].ClientSideEvents.ItemClick =
"function(s,e){return confirm('Are you sure you want to delete?')}";
protected void btnDelete_Click(object sender, MenuItemEventArgs e)
{
//Im using self written classes for handlig SQL logic it looks like this:
MySQLCommand commad = new MySQLCommand("delete_object");//procedure
commad.MyParam.AddWithValue("@ob_id", ObjectID);
commad.myExecuteNonQuery();
}
我是不是用错了JS函数?
现在,只要单击一个按钮(无论哪个按钮),您的代码都会删除您的对象。你需要做的是这样的:
protected void btnDelete_Click(object sender, MenuItemEventArgs e)
{
if (e.item.name === "Yes")
{
MySQLCommand commad = new MySQLCommand("delete_object");//procedure
commad.MyParam.AddWithValue("@ob_id", ObjectID);
commad.myExecuteNonQuery();
}
}
而不是 e.item.name
它可能是 e.item.text
或类似的东西,放置一个断点或 console.log
看看你的 e
属性 如果你不确定。