JS:Confirm()的一个问题.

MicrosoftCenterOfHN 2009-08-21 11:32:50
控件:ImageButton,有两个事件Click和Command
其OnClientClick="javascript:return confirm('确定删除吗?');

状况:当选择取消时,Click事件不会执行.但Command事件仍执行.

问题:能不能也不让Command事件执行?有什么办法?
...全文
248 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhoujianzhou 2009-08-22
  • 打赏
  • 举报
回复
<asp:ImageButton ID="ImageButton1"
ImageUrl="~/1c04c37aa9e0b1d10452b7ce82ce5f04.jpg" runat="server"
onclick="ImageButton1_Click" oncommand="ImageButton1_Command" OnClientClick="javascript:return window.confirm('ddd');" />

呵呵,那就其怪了.
toxxj 2009-08-22
  • 打赏
  • 举报
回复
如果一楼测试过了,把你的代码贴出来看下吧
  • 打赏
  • 举报
回复
发帖的时候我都写return 了,但页面里面去没有写.唉,对不住各位了.浪费大家时间了.
ws_hgo 2009-08-22
  • 打赏
  • 举报
回复
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function Check(evt){
evt = (evt) ? evt : ((window.event) ? window.event : "")
if (1<2){
alert("错误!");
evt.returnValue= false;
return false;
}
return confirm('正确');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server"
onitemcommand="Repeater1_ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="lb" Text="操作" CommandName="Select" runat="server" OnClientClick="return Check();"></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
<asp:Button ID="Button1" OnClientClick="return Check()" runat="server"
Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>
  • 打赏
  • 举报
回复
唉.惭愧,咋就没好好想想呢.这么简单的问题.
shankaipingo 2009-08-22
  • 打赏
  • 举报
回复
...应该执行的,可能你js有语法错误了.
gongsun 2009-08-22
  • 打赏
  • 举报
回复
...
ch219888 2009-08-22
  • 打赏
  • 举报
回复
顶下
zhubo_1117 2009-08-22
  • 打赏
  • 举报
回复
UP
maiker 2009-08-22
  • 打赏
  • 举报
回复
类似的问题,人家已经解决了
http://topic.csdn.net/u/20090820/18/a8d15595-5247-4e4b-a931-04961a750396.html
zhoujianzhou 2009-08-21
  • 打赏
  • 举报
回复
楼主,我测试过,怎么我的就不执行呢.
贴代码吧.

62,243

社区成员

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

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

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

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