4

I have asp.net button and on it's button click I am redirecting it using

Response.Redirect ("SomeURL.aspx");

I am not passing anything to SomeURL.aspx. Can this be achieved without a roundtrip to the server?

3 Answers 3

12

You could use an html anchor tag. This is the simplest approach and probably the best since anchors are the proper control to allow navigation.

<a href="SomeUrl.aspx">My link</a>

If you still want to use the asp.net button you could do something like this

<asp:Button runat="server" ID="myButton"
  OnClientClick="window.location.href='SomeURL.aspx'; return false;"
  Text="Submit"></asp:Button>
Sign up to request clarification or add additional context in comments.

Comments

1

You can try with this code - based on Javascript Navigate

window.navigate("SomeURL.aspx");

Sample

 <input type="button" value="Navigate to SomeURL" onclick="funcNavigate();"> 

  <script language="JavaScript">
  function funcNavigate() {
  window.navigate("SomeURL.aspx");
  }
  </script>

Comments

0

Can this be achieved without a roundtrip to the server?

Not using code behind.

However, you could wire up a client side click handler or use a hyperlink to accomplish the same thing.

<button onclick="window.location='SomeURL.aspx'; return false;">Some URL</a>

or

<a href="SomeURL.aspx">Some URL</a>

The hyperlink is the simplest answer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.