code behind with postback url

2.4k Views Asked by At

I try to make postpackurl in code behind so that I can send the code but my issue is when I click the button its keep it in the same page .

my question is how I can make the postbackurl directly go to next page?

3

There are 3 best solutions below

1
Indranil.Bharambe On

Use

response.redirect("frmdefault.aspx") 

in your button click code.

1
Seyed Morteza Mousavi On

Asp.net Button Has property named postbackurl which you can set postbackurl:

<asp:button id="Button2"
  text="Post value to another page" 
  postbackurl="Button.PostBackUrlPage2cs.aspx" 
  runat="Server">
</asp:button>
1
user2526236 On

In the ASPX file add the below Script:-

<script type="text/javascript">
function SomeMethod() {
    window.location.reload("nextpage.aspx");
    return false;
 }
</script>

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

When the user clicks on the button1 the nextpage.aspx page will be executed and no postback will happen on the current page