【问题标题】:ASP/Javascript onClientClick SecurityCheck()ASP/Javascript onClientClick SecurityCheck()
【发布时间】:2011-09-16 10:27:48
【问题描述】:

嘿,在确认 javascript 链接到另一个 aspx 文件后,它需要 javascript,但不知何故,它不会将浏览器定向到 url。这就是我得到的

<asp:ImageButton ID="Donebtn" runat="server" ImageUrl="~/images/done.jpg" ToolTip="Done. Add new activity" CommandName="Done" CommandArgument='<%#Eval("ActivityID") %>' OnClientClick="return SecurityCheck();" /> 

javascript

function SecurityCheck() 
  {

      return window("Mark Activity as completed and add new Activity?");
      if (o == true) 
      {
          window.location.href = 'CustomerHome.aspx?CustomerId=<%#Eval("CustomerID")%>';

      }
      else 
      {
          return window("No changes will be made");
      }
  }    

【问题讨论】:

    标签: javascript asp.net hyperlink onclientclick


    【解决方案1】:

    o 对象是什么?您需要使用以下内容:

    function SecurityCheck() 
    {
      var answer = confirm("Mark Activity as completed and add new Activity?");
      if (answer) 
      {
          window.location.href = 'CustomerHome.aspx?CustomerId=<%#Eval("CustomerID")%>';
      }
      else 
      {
          alert("No changes will be made");
          return false;
      }
    } 
    

    Live

    【讨论】:

    • 谢谢,但它仍然没有重定向到链接。我猜它不理解链接的格式?
    • 实际上我只是用google.com 替换了链接,它也不会将它指向那里。嗯
    • 我添加了实时示例。我不知道为什么它不适用于您的环境,但请确保您的功能在全球范围内可见。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-12
    • 2013-11-30
    • 2017-08-05
    • 1970-01-01
    • 2018-05-17
    • 2017-12-18
    • 1970-01-01
    相关资源
    最近更新 更多