Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Food1.aspx.cs" Inherits="Food1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
width: 165px;
}
.style2
{
width: 475px;
}
</style>

</head>
<body>
<form id="form1"  runat="server" action="https://test.switch.com" method="post" >
<asp:Button ID="Button2" runat="server"  onclick="Button2_Click"  Text="Button" />
<asp:Button ID="Button1" runat="server"  onclick="Button1_Click"  Text="Button" />
</form>
</body>

</html>

C#
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class fdd : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Test.aspx");
}

}

Both buttons onclick redirects to https://test.switch.com .i want button two to redirect to Test.aspx
Posted
Updated 21-Sep-15 11:45am
v2

Something like:

C#
<asp:button id="Button1" runat="server" postbackurl="~/Test.aspx" causesvalidation="false" text="Button" />


Here is a link for "DOCUMENTATION[^]"
 
Share this answer
 
v2
Remove action property from <form> as below.
i.e
ASP.NET
<form id="form1"  runat="server" method="post">
</form>
</form>

Or Else Provide PostbackUrl property to the button where u want different behaviour.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900