Asp.Net Button example to redirect to another page

Learn how to make a button in ASP.NET that sends you to another page! Easy steps with examples included.

ASPX file (Default.aspx):

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="YourNamespace.Default" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
            <!-- Button to trigger the redirection -->
            <asp:Button ID="RedirectButton" runat="server" Text="Redirect" OnClick="RedirectButton_Click" />

Code-behind file (Default.aspx.cs):

using System;
using System.Web.UI;

namespace YourNamespace
    public partial class Default : Page
        protected void RedirectButton_Click(object sender, EventArgs e)
            // Redirect to another page

In this example:

  • Default.aspx contains an ASP.NET button (RedirectButton) that will trigger a server-side event when clicked.
  • In the code-behind file (Default.aspx.cs), the RedirectButton_Click method handles the button click event.
  • Inside the RedirectButton_Click method, Response.Redirect is used to redirect the user to another page (in this case, "AnotherPage.aspx").

Make sure to replace "YourNamespace" with the appropriate namespace for your application, and "AnotherPage.aspx" with the actual URL of the page you want to redirect to.

Asp.Net Ajax Control Toolkit tutorials.

Give your valuable comments.

4 + 6 =

About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice