asp.net c#弹出确认/取消对话框

zestsnake 2014-06-12 11:34:58
protected void btnNext_ServerClick(object sender, EventArgs e)
{
……//先要执行一部分代码必须

//弹出一个确认,取消对话框

if (用户点的是确认)
{
……
}
else
return;
}

如何实现,弹出确认/取消对话框。当点确认运行其它代码,取消后不运行
...全文
616 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
啾啾我 2014-06-13
  • 打赏
  • 举报
回复
这种只能在前台js中实现的。
exiori 2014-06-13
  • 打赏
  • 举报
回复
Confirm("你确定要怎的?");
kkg_1473995421 2014-06-13
  • 打赏
  • 举报
回复
一、使用GridView控件 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" Font-Size="9pt" ForeColor="#333333" GridLines="None" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting" Width="500px"> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#E3EAEB" /> <Columns> <asp:BoundField DataField="ST_l_id" HeaderText="地址ID" /> <asp:BoundField DataField="ST_l_name" HeaderText="网站名称" /> <asp:BoundField DataField="ST_l_url" HeaderText="链接网址" /> <asp:HyperLinkField DataNavigateUrlFields="ST_l_id" DataNavigateUrlFormatString="AmendLink.aspx?ID={0}" HeaderText="修改" Text="修改" /> <asp:CommandField HeaderText="删除" ShowDeleteButton="True" /> </Columns> <SelectedRowStyle BackColor="#C5BBAF" ForeColor="#333333" Font-Bold="True" /> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#7C6F57" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> 二、处理程序如: protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { SqlData da = new SqlData(); da.ExceSQL("delete from ST_link where ST_l_id='" + GridView1.DataKeys[e.RowIndex].Value + "'"); Page.Response.Redirect("LinkManage.aspx"); } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind();//CodeGo.net } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.Cells[1].Text).Length > 6) { e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…"; } if ((e.Row.Cells[0].Text).Length > 6) { e.Row.Cells[0].Text = (e.Row.Cells[0].Text).Substring(0, 6) + "…"; } if ((e.Row.Cells[0].Text).Length > 6) { e.Row.Cells[0].Text = (e.Row.Cells[0].Text).Substring(0, 6) + "…"; } } if (e.Row.RowType == DataControlRowType.DataRow) { ((LinkButton)(e.Row.Cells[4].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')"); }
清秋喜乐 2014-06-12
  • 打赏
  • 举报
回复
webform,用js写个相应的方法,然后指定onclick事件。判断的话用confirm winform,if (MessageBox.Show("确定", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { //do sth } else { return; }
  • 打赏
  • 举报
回复
你这是Web应用。你这种功能不可能实现。当你实现弹出对话框的时候,这一次请求就已经结束。下一次请求不会从弹出对话框的位置继续执行。
czhsoftware 2014-06-12
  • 打赏
  • 举报
回复
在page_onload事件里给你要点击的按钮添加如下属性 this.SubmitButton.Attributes.Add("onclick", "return confirm('你确定提交吗?');");
淡淡的活着 2014-06-12
  • 打赏
  • 举报
回复
web里似乎真不能··
ojekleen 2014-06-12
  • 打赏
  • 举报
回复
JS操作 Confirm("你确定要怎的?"); 如果是服务端控件:OnClientClick

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧