Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET URL Navigation

Tags:

asp.net

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?

like image 349
kalls Avatar asked Sep 17 '25 17:09

kalls


2 Answers

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>
like image 160
Claudio Redi Avatar answered Sep 20 '25 08:09

Claudio Redi


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>
like image 36
Aghilas Yakoub Avatar answered Sep 20 '25 09:09

Aghilas Yakoub