When user click on the button "back",it should go back to "HomeStudent.aspx",but unfortunately its not working and no error shown.Do help me.

<%@ Page Title="Advertisement" Language="C#" MasterPageFile="~/AccommodationStudent.master" AutoEventWireup="true"
    CodeFile="Advertisement.aspx.cs" Inherits="Advertisement" %>

<%@ Register TagPrefix="ajax" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> 


    <style type="text/css">
        .style1
        {
            width: 224px;
        }
    </style>   


</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="main_ContentPlaceHolder" runat="Server">
    <asp:UpdatePanel ID="OuterPanel" 
                             UpdateMode="Conditional" 
                             runat="server">
                <ContentTemplate>
    <div style="margin: 20px 20px 20px 20px;">
        <table style="border: 1px solid #D8D8D8; width: 100%;" cellpadding="5">
            <tr>
                <td style="background: #D8D8D8; color: black; font-family: Arial; font-size: 13px;
                    font-weight: bold; height: 30px;" colspan="4">
                    <span style="margin: 20px 20px 20px 20px;">Advertisement</span>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <asp:Label ID="lbl_msg" runat="server" Style="color:Red;"
                        Text="" Visible="False"></asp:Label>
                </td>
            </tr>

             <tr>
                <td style="font-family: Arial; font-size: 12px;
                    font-weight: bold; height: 30px;" colspan="4">
                    <span style="margin: 20px 20px 20px 20px;">Agent Details</span>
                </td>
            </tr>

            <tr>
                <td style="text-align: right;" >
                    <asp:Label ID="lbl_Name" runat="server" Text="Name:"></asp:Label>
                </td>
                <td>
                <asp:Label ID="lbl_agtName" runat="server" Text="Label"></asp:Label>

                </td>
                <td style="text-align: right;" class="style1">
                    <asp:Label ID="lbl_phoneNum" runat="server" Text="Phone Number:"></asp:Label>
                </td>
                <td>
              <asp:Label ID="lbl_agtPhoneNum" runat="server" Text="Label"></asp:Label>


                </td>
            </tr>
            <tr>
                <td style="text-align: right;"  >
                    <asp:Label ID="lbl_add" runat="server" Text="Address:"></asp:Label>
                </td>
                <td >
             <asp:Label ID="lbl_agtAdd" runat="server" Text="Label"></asp:Label>

                </td>
                <td style="text-align: right;" class="style1" >
                    <asp:Label ID="lbl_email" runat="server" Text="Email:"></asp:Label>
                </td>
                <td >
               <asp:Label ID="lbl_agtEmail" runat="server" Text="Label"></asp:Label>                 

                </td>
            </tr>

               <tr>
                <td style="font-family: Arial; font-size: 12px;
                    font-weight: bold; height: 30px;" colspan="4">
                    <span style="margin: 20px 20px 20px 20px;">Accommodation Details</span>
                </td>
            </tr>

            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lbl_unitAdd" runat="server" Text="Unit Address:"></asp:Label>
                </td>
                <td>
                   <asp:Label ID="lbl_agtUnitAdd" runat="server" Text="Label"></asp:Label>
                </td>
                <td style="text-align: right;" class="style1">
                    <asp:Label ID="lbl_location" runat="server" Text="Location:"></asp:Label>
                </td>
                <td>
                   <asp:Label ID="lbl_agtLocation" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td  style="text-align: right;">
                    <asp:Label ID="lbl_types" runat="server" Text="Types:"></asp:Label>
                </td>
                <td >
                    <asp:Label ID="lbl_agtType" runat="server" Text="Label"></asp:Label>             
                </td>
                <td  style="text-align: right;" class="style1">
                    <asp:Label ID="lbl_description0" runat="server" Text="Description:"></asp:Label>
                </td>
                <td >
                <asp:Label ID="lbl_agtDescription" runat="server" Text="Label"></asp:Label>                   
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
               </td>
                <td>
                </td>
                <td colspan="2">
                    <asp:Label ID="lbl_availability" runat="server" Font-Underline="True" 
                        style="font-weight: 700; " Text="Availability"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lbl_room1" runat="server" Text="Room1(RM):"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lbl_r1" runat="server" Text="Label"></asp:Label>
                </td>
                <td colspan="2">
                    <asp:Label ID="lbl_rbt1" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lbl_room2" runat="server" Text="Room2(RM):"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lbl_r2" runat="server" Text="Label"></asp:Label>
                </td>
                <td colspan="2">                  
                      <asp:Label ID="lbl_rbt2" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lbl_room3" runat="server" Text="Room3(RM):"></asp:Label>
                </td>
                <td >
                    <asp:Label ID="lbl_r3" runat="server" Text="Label"></asp:Label>
                </td>
                <td  colspan="2">                  
                     <asp:Label ID="lbl_rbt3" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lbl_room4" runat="server" Text="Room4(RM):"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lbl_r4" runat="server" Text="Label"></asp:Label>
                </td>
                <td colspan="2">                
                      <asp:Label ID="lbl_rbt4" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lbl_room5" runat="server" Text="Room5(RM):"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lbl_r5" runat="server" Text="Label"></asp:Label>
                </td>
                <td colspan="2">                
                     <asp:Label ID="lbl_rbt5" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lbl_total0" runat="server" Text="Total Unit(RM):"></asp:Label>
                </td>
                <td colspan="3">
                 <asp:Label ID="lbl_ttlunit" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td  style="text-align: center;"colspan="4">                    

                    <asp:Button ID="btn_back" runat="server" OnClick="btn_back_Click"  Text="Back" />                    

                </td>
                <tr>
                    <td colspan="4" >                       
                        </td>
                </tr>

            </tr>
        </table>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

`

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Configuration;
using System.Data.SqlClient;

public partial class Advertisement : System.Web.UI.Page
{
    //public static string _strcatid;
    public static int _strcatid = 0;
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string _xid = Request.QueryString["ID"].ToString();
            conn.Open();
            SqlCommand cmd = new SqlCommand(" SELECT Agent.Name,Agent.Address,Agent.PhoneNum,Agent.EmailID,Advertisement.UnitAddress,Advertisement.Location,Advertisement.Types,Advertisement.Description,Advertisement.Room1,Advertisement.Room2,Advertisement.Room3,Advertisement.Room4,Advertisement.Room5,Advertisement.TotalUnit,Advertisement.Availability1,Advertisement.Availability2,Advertisement.Availability3,Advertisement.Availability4,Advertisement.Availability5 FROM Agent LEFT JOIN Advertisement ON Agent.AgentID = Advertisement.AgentID WHERE AdverID =" + _xid + "", conn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);

            if (ds.Tables[0].Rows.Count > 0)
            {
                //_strcatid = ds.Tables[0].Rows[0]["AgentUser"].ToString();
                //_strcatid = Convert.ToInt32(ds.Tables[0].Rows[0]["AgentID"].ToString());
                lbl_agtName.Text = ds.Tables[0].Rows[0]["Name"].ToString();
                lbl_agtAdd.Text = ds.Tables[0].Rows[0]["Address"].ToString();
                lbl_agtPhoneNum.Text = ds.Tables[0].Rows[0]["PhoneNum"].ToString();
                lbl_agtEmail.Text = ds.Tables[0].Rows[0]["EmailID"].ToString();


                lbl_agtUnitAdd.Text = ds.Tables[0].Rows[0]["UnitAddress"].ToString();
                lbl_agtLocation.Text = ds.Tables[0].Rows[0]["Location"].ToString();
                lbl_agtType.Text = ds.Tables[0].Rows[0]["Types"].ToString();
                lbl_agtDescription.Text = ds.Tables[0].Rows[0]["Description"].ToString();
                lbl_r1.Text = ds.Tables[0].Rows[0]["Room1"].ToString();
                lbl_r2.Text = ds.Tables[0].Rows[0]["Room2"].ToString();
                lbl_r3.Text = ds.Tables[0].Rows[0]["Room3"].ToString();
                lbl_r4.Text = ds.Tables[0].Rows[0]["Room4"].ToString();
                lbl_r5.Text = ds.Tables[0].Rows[0]["Room5"].ToString();
                lbl_ttlunit.Text = ds.Tables[0].Rows[0]["TotalUnit"].ToString();
                lbl_rbt1.Text = ds.Tables[0].Rows[0]["Availability1"].ToString();
                lbl_rbt2.Text = ds.Tables[0].Rows[0]["Availability2"].ToString();
                lbl_rbt3.Text = ds.Tables[0].Rows[0]["Availability3"].ToString();
                lbl_rbt4.Text = ds.Tables[0].Rows[0]["Availability4"].ToString();
                lbl_rbt5.Text = ds.Tables[0].Rows[0]["Availability5"].ToString();


            }
        }
        conn.Close();

    }


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

`

Is the page even posting back when you click the button?

no..its not posting back..freeze on the current page itself

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.