Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 320823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:47:20+00:00 2026-05-12T08:47:20+00:00

Among other, I have two pages in my Web Site project. Default.aspx and TeacherControlPanel.aspx.

  • 0

Among other, I have two pages in my Web Site project. Default.aspx and TeacherControlPanel.aspx.

User gives his credentials in Default.aspx, a cookie is created And then he is Server.Transfer()ed to TeacherControlPanel.aspx.

TeacherControlPanel.aspx has a logout-button and another button named ‘Send Mail’.

If the user presses the logout-button, the cookie is deleted and he is redirected to Default.aspx.

If the user closes the browser without logging out, when he opens the Default.aspx page, he is automatically redirected to TeacherControlPanel.aspx coz the cookie is there.

Now, everything is working fine except I am pressing a ‘Send Mail’ button on TeacherControlPanel.aspx then Default.aspx is being loaded and then TeacherControlPanel.aspx is loaded but Button event handler is not being executed.

Why Default.aspx is loading again and what is happening to Button event?

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">

    <table>
        <tr>
        <td><asp:HyperLink ID="homePageHyperlink" runat="server" NavigateUrl="~/Default.aspx">Home</asp:HyperLink></td>        
        <td rowspan="5">&nbsp;<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        </asp:contentplaceholder></td>
        </tr>
        <tr>
        <td><asp:HyperLink ID="studentControlPanelHyperlink" runat="server">Student</asp:HyperLink></td>        
        </tr>
        <tr>
        <td></td>        
        </tr>
        <tr>
        <td></td>  
        </tr>
        <tr>
        <td></td>   
        </tr>
    </table>    
    </form>
</body>
</html>


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string st = "";
    }
}


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table style="width: 253px; height: 118px">
        <tr>
            <td style="width: 54px">
            </td>
            <td colspan="2">
            </td>
        </tr>
        <tr>
            <td align="right" style="width: 54px">
                <asp:Label ID="Label1" runat="server" Text="Username :"></asp:Label></td>
            <td colspan="2">
                <asp:TextBox ID="usernameTextBox" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td style="width: 54px">
                <asp:Label ID="Label2" runat="server" Text="Passord  :"></asp:Label></td>
            <td colspan="2">
                <asp:TextBox ID="passwordTextBox" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td style="width: 54px">
            </td>
            <td colspan="2">
                <asp:Button ID="btnLogin" runat="server" OnClick="btnLogin_Click" Text="Login" /></td>
        </tr>
        <tr>
            <td colspan="3">
                <asp:Label ID="labLoginMessage" runat="server" Font-Bold="True" Font-Names="Verdana"
                    Font-Size="Small" ForeColor="#C00000" Text="Label" Width="226px"></asp:Label></td>
        </tr>
    </table>
</asp:Content>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Ice_Web_Portal.BO;
using Ice_Web_Portal.ASP.NET.Utils;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AspNetUtil util = new AspNetUtil(this);

        util.DisposeCookie("user");

        UserTypeEnum userType = EnumUtility.ConvertToEnum(util.GetCookieValue("user", "usertype"));
        string username = util.GetCookieValue("user", "username");

        if (userType == UserTypeEnum.Student)
        {
            Server.Transfer("~/Student/StudentControlPanel.aspx?username=" + username);
        }
        else if (userType == UserTypeEnum.Teacher)
        {
            Server.Transfer("~/Teacher/TeacherControlPanel.aspx?username=" + username);
        }
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string username = this.usernameTextBox.Text;
        string password = this.passwordTextBox.Text;

        bool success = Ice_Web_Portal.BO.User.LogIn(username, password);

        if (success)
        {
            Ice_Web_Portal.BO.User user = Ice_Web_Portal.BO.User.GetUserByUserName(username);

            Ice_Web_Portal.BO.UserTypeEnum loginUserType = user.UserTypeEnum;

            if (loginUserType == UserTypeEnum.Student)
            {
                AspNetUtil util = new AspNetUtil(this);
                util.SaveInCookie("user", "username", username, 3600);
                util.SaveInCookie("user", "usertype", "Student", 3600);

                Server.Transfer("~/Student/StudentControlPanel.aspx?username=" + username);
            }
            else if (loginUserType == UserTypeEnum.Teacher)
            {
                AspNetUtil util = new AspNetUtil(this);
                util.SaveInCookie("user", "username", username, 3600);
                util.SaveInCookie("user", "usertype", "Teacher", 3600);

                Server.Transfer("~/Teacher/TeacherControlPanel.aspx?username=" + username);                
            }
            else
            {
                labLoginMessage.Text = "Sorry! Type of user couldn't be determined!";
            }
        }
        else
        {
            labLoginMessage.Text = Ice_Web_Portal.BO.User.LoginMessage;
        }
    }
}

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TeacherControlPanel.aspx.cs" Inherits="Teacher_TeacherControlPanel" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table style="width: 346px">
        <tr>
            <td>
                <asp:Label ID="labErrorMessage" runat="server" Font-Bold="True" Font-Names="Verdana"
                    Font-Size="Small" ForeColor="#C00000" Text="Error Message"></asp:Label></td>
            <td>
                </td>
            <td>
                </td>
            <td>
                </td>
        </tr>
        <tr>
            <td>
                Teacher Control Panel</td>
            <td>
                Mails</td>
            <td>
                Notices</td>
            <td>
                Uploads</td>
        </tr>
        <tr>
            <td rowspan="3">
                <table style="width: 134px">
                    <tr>
                        <td>
                            Username:</td>
                        <td>
                            <asp:Label ID="labUsername" runat="server" Text="labUsername"></asp:Label></td>
                        <td>
                            Teacher Code:
                        </td>
                        <td style="width: 3px">
                            <asp:Label ID="labTeacherCode" runat="server" Text="labTeacherCode"></asp:Label></td>

                    </tr>
                    <tr>
                        <td>
                            Name :</td>
                        <td>
                            <asp:Label ID="labName" runat="server" Text="labName"></asp:Label></td>
                        <td>
                            Department</td>
                        <td style="width: 3px">
                            <asp:Label ID="labDepartment" runat="server" Text="labDepartment"></asp:Label></td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td style="width: 3px">
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td style="width: 3px">
                        </td>
                    </tr>
                </table>
            </td>
            <td>
                <asp:Button ID="btnSendMail" runat="server" Height="24px" Text="Send Mail" Width="130px" OnClick="btnSendMail_Click" PostBackUrl="~/Teacher/TeacherControlPanel.aspx" /></td>
            <td>
                <asp:Button ID="btnSubmitNewNotice" runat="server" Height="24px" Text="Submit New Notice"
                    Width="130px" /></td>
            <td>
                <asp:Button ID="btnViewUploads" runat="server" Height="24px" Text="ViewUploads" Width="130px" /></td>
        </tr>
        <tr>
            <td>
                <asp:Button ID="btnViewOldMails" runat="server" Text="View Old Mails" OnClick="btnViewOldMails_Click" /></td>
            <td>
                <asp:Button ID="btnViewOldNotices" runat="server" Height="24px" Text="View Old Notices"
                    Width="130px" /></td>
            <td>
                <asp:Button ID="btnViewDefaulters" runat="server" Height="24px" Text="View Defaulters"
                    Width="130px" /></td>
        </tr>
        <tr>
            <td>
                <asp:Button ID="btnReceivedMails" runat="server" Height="24px" Text="Received Mails"
                    Width="130px" /></td>
            <td>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td colspan="4" rowspan="1">
                <asp:GridView ID="UploadsGridView1" runat="server">
                </asp:GridView>
            </td>
        </tr>
    </table>
</asp:Content>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Ice_Web_Portal.ASP.NET.Utils;
using Ice_Web_Portal.BO;

public partial class Teacher_TeacherControlPanel : System.Web.UI.Page
{
    string username = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            username = (string)Request.QueryString["username"];

            Teacher teacher = Teacher.GetTeacherByUsername(username);

            if (teacher != null)
            {
                labUsername.Text = username;
                labName.Text = teacher.TeacherName;
                labTeacherCode.Text = teacher.TeacherCode;

                Dept dept = teacher.Department;

                if (dept != null)
                {
                    labDepartment.Text = dept.DeptName;
                }
            }
            else
            {
                labErrorMessage.Text = "No teacher found";
            }
        }
    }

    protected void btnSendMail_Click(object sender, EventArgs e)
    {
        //try
        {
            Server.Transfer(@"~/Teacher/TeacherSendMail.aspx?username=" + username);
            //Response.Redirect(@"~/Student/StudentSendMail.aspx?username=" + username);
        }
        //catch (Exception ex)
        {
            string m;
        }
    }

    protected void btnViewOldMails_Click(object sender, EventArgs e)
    {
        //try
        {
            Server.Transfer(@"~/Teacher/TeacherOldMail.aspx?username=" + username);
            //Response.Redirect(@"~/Student/StudentSendMail.aspx?username=" + username);
        }
        //catch (Exception ex)
        {
            string m;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:47:21+00:00Added an answer on May 12, 2026 at 8:47 am

    Does this also happen when you use Response.Redirect instead of Server.Transfer? What URL are you seeing in the browser address bar after the Server.Transfer?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a total of 3 pages; form elements are distributed among two pages,
If I have a table that (among other columns) has two DATETIME columns, how
I have a web application which among other things contains a table of items
I have a TabControl, and among other tabs I have one called Errors. I
I have a database which stores (among other things), the following pieces of information:
I have an MSBuild task that executes (among other things) a call to xcopy.
I have a test that is successful (among other things) if a certain callback
I have developed a control in C#. Among other things this control can popup
I have an interface that, among other things, implements a public IEnumerator GetEnumerator() method,
I have a stored procedure that does, among other stuff, some inserts in different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.