[英]How to perform OnClientClick before OnClick?
我在listView
內有帶有OnClick
事件和OnClientClick
按鈕。 onClientClick
具有JS功能確認('sure ??')。 確認消息應在特定條件下回發之前出現。 如何根據listview itemDataBound()
內部的條件執行onClientClick
?
碼:
protected void lvCo_ItemDataBound(object sender, ListViewItemEventArgs e){
int Req = Convert.ToInt32(((Label)e.Item.FindControl("lblCoId")).Text);
if (Req==5)
// Show Confirmation Message
else
// Don't Show the Confirmation Message
}
aspx:
<asp:ListView ID="lvCo" runat="server" DataKeyNames="CoId" OnItemCommand="lvCoFind_ItemCommand" OnItemDataBound="lvCo_ItemDataBound">
// .. Layouttemplate .. && Itemtemplate
<asp:Button Text="Save" ID="btSaveOp" CommandName="Save" runat="server" OnClientClick="if (!confirm('Are you sure?')) return false;" />
不確定是否可行,但是如何將onclientclick移出aspx頁面並將其設置在后面的代碼中。
protected void lvCo_ItemDataBound(object sender, ListViewItemEventArgs e){
int Req = Convert.ToInt32(((Label)e.Item.FindControl("lblCoId")).Text);
if (Req==5) // Show Confirmation Message
((Button)e.Item.FindControl("btSaveOp")).OnClientClick = "if (!confirm('Are you sure?')) return false;";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.