Q:

Label.Visible=true is not working

I have an aspx page (a login page). When a user enters userno & pw fields and clicks on "Ok" button, the user redirects to Default.aspx page. If user does not login succesfully, a label control will show up (Label.visible will be true in codebehind). 
Somehow Visible=true is not working.
This is Html:
<%@ Page Title="" Language="C#" MasterPageFile="~/SiteEntree.master" AutoEventWireup="true" Inherits="WebApp.Login" Codebehind="Login.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

       <div id="isDiv">
       <div id="divNoteBox">
       </div>
       <div id="loginBox" class="formLayout">
             <label>User No: </label><asp:TextBox runat="server" ID="txtUno" />
             <br />
             <label>Password:</label><asp:TextBox runat="server" ID="txtPw" />
           <asp:Label runat="server" Visible="false" ID="lblMsg" Text="a message to warn.." />
             <asp:LinkButton runat="server" ID="lbtn" Text="Ok" OnClick="lbtn_Click" CssClass="lbClass" />
       </div>  
    </div>
</asp:Content>

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

            }

    protected void lbtn_Click(object sender, EventArgs e)
            {
                using (DBEntities context = new DBEntities())
                {
                    int? val = context.checkUser(Convert.ToInt32(txtUno.Text), txtPw.Text).SingleOrDefault();
                    if(val!=null)
                    {
                        int? r = val;
                        if (r == -1)
                        {
                            Response.Redirect("Login.aspx");
                            lblMsg.Visible = true;
                        }
                        else if (r == 1)
                        {
                            Response.Redirect("Default.aspx");
                        }
                }
            }
     }
}

Could you help please, Thanks.

A:

You're redirecting the user to another page.  The code to set the visibility will never even be run; the act of redirecting stops the rendering for the page.  If you weren't redirecting, then you'd see the label's visibility change.

