Failed to redirect to another page using Javascript

In the html file to redirect the page using Javascript, which I used as

window.location.href = "http://www.google.com/";

Works great. But when I tried in .aspx, it does not work. Below is my code. thanks in advance

<head runat="server">
<script type="text/javascript">
   function PageRedirect() {
       window.location.href = "http://www.google.com/";
   }
 </script>
</head>
<body>
<form runat="server">
  <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="PageRedirect()"/>
  </form>
+5
source share
1 answer

Try the following:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="PageRedirect(); return false;"/>
+7
source

All Articles