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 7976899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:02:22+00:00 2026-06-04T09:02:22+00:00

i have the following loginview code in my site.master design <asp:LoginView ID=HeadLoginView runat=server EnableViewState=false>

  • 0

i have the following loginview code in my site.master design

<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
                <AnonymousTemplate>
                    [ <a href="Log.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
                </AnonymousTemplate>
                <LoggedInTemplate>
                    Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
                    [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
                </LoggedInTemplate>
            </asp:LoginView>

the log.aspx.cs file has the following code:

 protected void Page_Load(object sender, EventArgs e)
    {
        Master.FindControl("CAMenu").Visible = false;
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (txtUsername.Text == "admin" && txtPassword.Text == "1234")
        {
            Response.Redirect("NewEvent.aspx");
        }
    }

but the login view is not updating to Welcome “Username”.. whats the mistake here. Should i change anything??? Please help

  • 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-06-04T09:02:23+00:00Added an answer on June 4, 2026 at 9:02 am

    In Login.Aspx i made the following changes..

    protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Master.FindControl("CAMenu").Visible = false;
                Master.FindControl("loginStatus").Visible = false;
            }
            catch (Exception ex)
            {
                new Logger().Log("ShortCom.Login.btnLogin_Click(object sender, EventArgs e)", ex.Message);
                Response.Redirect("~/Error.aspx");
            }
        }
        protected void LoadMessageBox(string MessageID)
        {
            try
            {
                messages = new GUIMessages();
                popupExtend = new ModalPopupExtender();
                lbMessage = (Label)Master.FindControl("label5");
                lbMessage.Text = messages.GetGUIMessage(GUIModule.Login, MessageID);
                popupExtend = (ModalPopupExtender)Master.FindControl("popupExtender");
                popupExtend.Show();
            }
            catch (Exception ex)
            {
                new Logger().Log("ShortCom.Login.LoadMessageBox(string MessageID)", ex.Message);
                Response.Redirect("~/Error.aspx");
            }
        }
    
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = txtUsername.Text;
                string password = txtPassword.Text;
    
                if (userName == string.Empty && password == string.Empty)
                {
                    LoadMessageBox("5");
                    txtUsername.Focus();
    
    
                    return;
                }
                if (userName == string.Empty)
                {
                    LoadMessageBox("1");
                    txtUsername.Focus();
                    return;
                }
                else if (password == string.Empty)
                {
                    LoadMessageBox("3");
    
                    txtPassword.Focus();
                    return;
                }
    
                User user = new User(userName);
                DataTable tab = new DataTable();
                tab = user.GetUserDetails(userName);
                string firstName = string.Empty;
                string userPassword = string.Empty;
                string RoleID = string.Empty;
                string userID = string.Empty;
                Session["UserName"] = userName;
                if (tab.Rows.Count == 0)
                {
                    LoadMessageBox("6");
                    txtPassword.Text = string.Empty;
                    txtUsername.Text = string.Empty;
                    txtUsername.Focus();
                    return;
                }
    
                if (tab.Rows.Count == 1)
                {
                    userID = tab.Rows[0][0].ToString();
                    firstName = tab.Rows[0][1].ToString();
                    userPassword = tab.Rows[0][2].ToString();
                    RoleID = tab.Rows[0][3].ToString();
                    Session["UserID"] = userID;
                }
    
                    if (userPassword == password)
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                    else
                    {
                        LoadMessageBox("4");
                        txtPassword.Focus();
                        return;
                    }
    
            }
            catch (Exception ex)
            {
                new Logger().Log("ShortCom.Login.btnLogin_Click(object sender, EventArgs e)", ex.Message);
                Response.Redirect("~/Error.aspx");
            }
        }
    

    And in Site.Master:-

    protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                if (Page.Title != "Login")
                {
                    if (Session.Count == 0 || Session["Username"] == null)
                        Response.Redirect("~/Login.aspx", true);
                    CheckRole();
    
                }
                lblDateTime.Text = "";
            }
            catch (Exception ex)
            {
                new Logger().Log("ShortCom.SiteMaster.Page_Load()(object sender, EventArgs e)", ex.Message);
                Response.Redirect("~/Error.aspx");
            }
          }
    
        public void CheckRole()
        {
            try
            {
                if (System.Web.HttpContext.Current.Session.Count > 0)
                {
                    string firstName = string.Empty;
                    // string userPassword = string.Empty;
                    string RoleID = string.Empty;
                    Common common = new Common();
                    DataTable tab = new DataTable();
                    string userName = (string)Session["UserName"];
                    User user = new User(userName);
                    tab = user.GetUserDetails(userName);
    
                    if (tab.Rows.Count == 1)
                    {
                        firstName = tab.Rows[0][1].ToString();
                        RoleID = tab.Rows[0][3].ToString();
                    }
    
                    if (RoleID != "1")
                    {
                        int count = CAMenu.Items.Count;
                        if (count == 5)
                        {
                            for (int menuCount = 3; menuCount > 0; menuCount--)
                            {
                                string text = CAMenu.Items[menuCount - 1].Text;
                                CAMenu.Items.RemoveAt(menuCount - 1);
                            }
                        }
                        lbLoginMessage.Text = "Welcome," + " " + firstName;
                        loginStatus.Visible = true;
                    }
                    else
                    {
                        lbLoginMessage.Text = "Welcome," + " " + firstName;
                        loginStatus.Visible = true;
                    }
    
                }
                else
                {
                    Session.Abandon();
                    Response.Redirect("~/Login.aspx", true);
                }
            }
            catch (Exception ex)
            {
                new Logger().Log("ShortCom.SiteMaster.CheckRole()", ex.Message);
                Response.Redirect("~/Error.aspx");
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ASP.NET membership in a web application. I have the following code
I have following code in my application: // to set tip - photo in
I have following code in my Application. Comments in my code will specify My
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
I have the following code in my registration page to go to a paypal
In the following code, I have determined that everything works, up until [tableView reloadData]
I have the following log in status controls on the top of my master
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
I'm having issues with the following. Atm i have a LoginView that sends the
I have following code that creates Linq query. I've never used Linq until today

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.