Jagadesh
Jagadesh

Reputation: 374

Unable to Redirect to another page using Javascript

In html file to redirect a page using Javascript i used like this

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

Its working fine. But when i tried in .aspx it is not working 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>

Upvotes: 6

Views: 8833

Answers (1)

karaxuna
karaxuna

Reputation: 26930

Try this:

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

Upvotes: 8

Related Questions