C# 如何在OnClick之前执行OnClientClick?

C# 如何在OnClick之前执行OnClientClick?,c#,jquery,asp.net,C#,Jquery,Asp.net,我有一个带有OnClick事件和OnClientClick的按钮,在列表视图中。onClientClickhave JS函数confirm('sure??')。根据具体情况,在回发之前应显示确认消息。如何根据listviewitemDataBound()中的条件在客户端单击时执行该操作 代码: aspx: // .. Layouttemplate..&&项目模板 不确定这是否可行,但将onclientclick移出aspx页面并在代码隐藏中进行设置怎么样 protected void lvCo

我有一个带有
OnClick
事件和
OnClientClick
的按钮,在
列表视图中。
onClientClick
have JS函数confirm('sure??')。根据具体情况,在回发之前应显示确认消息。如何根据listview
itemDataBound()
中的条件在客户端单击时执行该操作

代码:

aspx:


// .. Layouttemplate..&&项目模板

不确定这是否可行,但将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;";

条件是什么?代码是什么?我不明白你在这方面遇到了什么问题。很抱歉,我会复制代码
<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;" />
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;";