【发布时间】:2014-12-22 14:06:29
【问题描述】:
我在 Gridview 中有一个 ButtonField,我正在使用 onRowCommand 来触发操作。如果用户单击“取消”,我需要 onRowCommand 事件中的确认框来返回/跳过代码
这里是grid.aspx.cs
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string commandname = e.CommandName;
if (commandname.Equals("atender"))
{
// here there are the codes...I need a confirmation box here which skip these codes if the user click in cancel
}
}
这是我gridview的asp
<asp:GridView ID="GridView1" runat="server" CellPadding="4"
BorderStyle="None" BorderWidth="0px" CellSpacing="1" Width="100%"
GridLines="Vertical" AllowPaging="True" onrowcommand="GridView1_RowCommand"
onselectedindexchanged="GridView1_SelectedIndexChanged"
onpageindexchanging="GridView1_PageIndexChanging"
onrowdatabound="GridView1_RowDataBound" PageSize="5" HorizontalAlign=Left
>
<PagerStyle HorizontalAlign="Center" />
<RowStyle CssClass="tabela_texto2" HorizontalAlign="Center"
VerticalAlign="Middle" />
<AlternatingRowStyle CssClass="tabela_texto1" />
<Columns>
<asp:ButtonField Text="Status" CommandName="atender" ButtonType="Button" />
<asp:ButtonField Text="Ver no mapa" CommandName="ver" ButtonType="Button" />
</Columns>
</asp:GridView>
【问题讨论】:
-
确认框需要javascript,并且必须在服务器受到点击之前打开它
-
如何在这段代码中添加这个javascript?你能帮帮我吗?
标签: asp.net .net visual-studio