0
我在我的網頁表單的JavaScript函數如下:代碼隱藏方法不javascript函數後甚至解僱返回true
<script type="text/javascript">
function deleteNodeAssets() {
var isdeletable = document.getElementById("<%=hdisDeletable.ClientID %>").value;
if (isdeletable == "False") {
alert("This item can't be deleted!");
return false;
}
else {
var treeView = $find("<%=tvAssets.ClientID%>");
var allNodes = treeView.get_allNodes();
if (allNodes.length < 1) {
alert("The treeview is empty.");
return false;
}
var selectedNode = treeView.get_selectedNode();
if (!selectedNode) {
alert("You need to select an item first.");
return false;
}
var childs = selectedNode.get_childListElement();
if (childs != null || childs == "") {
if (!confirm("This item contains sub-groups. Are you sure you want to delete all related items?"))
return false;
}
if (allNodes.length == 1) {
if (!confirm("This is the last item in the treeview. Are you sure you want to delete it?"))
return false;
}
if (confirm("Are you sure you want to delete the item?")) {
return true;
}
}
}
</script>
這是點擊期間刪除按鈕激發
<asp:Button ID="btnRemoveNodeAssets" runat="server" OnClientClick="return deleteNodeAssets();"
Text="Remove Item" OnClick="btnRemoveNodeAssets_Click" />
我的問題我面臨的是,即使deleteNodeAssets()
返回true
我的代碼隱藏方法btnRemoveNodeAssets_Click
根本不會觸發。
它的工作原理...日Thnx。如果你不介意你能解釋它爲什麼工作..我不明白最後2行'所以如果你的方法返回false,然後返回值,如果reutrn false然後什麼都不做,那麼onClick將被稱爲'。 – TFrost
如果您附加客戶端單擊處理程序的這種按鈕,返回一個值,它將阻止執行腳本後附加的代碼 –
然後返回時,只有當驗證是假的 –