protected void Page_Load(object sender, EventArgs e)
 {
     Block1.DataBind();
     if (!this.IsPostBack)
     {
         ViewState["LoginErrors"] = 0;
     }
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Block1.DataBind();
        loginblock.DataBind();
        try
        {
            //  Block3.DataBind();
            if (!this.IsPostBack)
            {
                ViewState["LoginErrors"] = 0;
                if (Session["clients"] != null)
                {
                    LinkButton lnkuser2 = loginblock.ContentPlaceholder.Controls[0].FindControl("LinkButton2") as LinkButton;
                    LinkButton lnkuser  = loginblock.ContentPlaceholder.Controls[0].FindControl("LinkButton3") as LinkButton;
                    LinkButton lnkuser1 = loginblock.ContentPlaceholder.Controls[0].FindControl("LinkButton1") as LinkButton;
                    lnkuser.Text     = "HELLO:   " + (string)(Session["clients"]);
                    lnkuser2.Visible = true;
                    lnkuser1.Visible = false;
                    lnkuser.Visible  = true;
                }
                else
                {
                    LinkButton lnkuser1 = loginblock.ContentPlaceholder.Controls[0].FindControl("LinkButton1") as LinkButton;
                    LinkButton lnkuser2 = loginblock.ContentPlaceholder.Controls[0].FindControl("LinkButton2") as LinkButton;
                    LinkButton lnkuser  = loginblock.ContentPlaceholder.Controls[0].FindControl("LinkButton3") as LinkButton;
                    lnkuser2.Visible = false;
                    lnkuser1.Visible = true;
                    lnkuser.Visible  = false;
                }

                if (Session["USERS"] != null)
                {
                    LinkButton lnkuser1 = Block1.ContentPlaceholder.Controls[0].FindControl("linkAdmin") as LinkButton;
                    LinkButton lnkuser2 = Block1.ContentPlaceholder.Controls[0].FindControl("linkBack") as LinkButton;
                    LinkButton lnkuser3 = Block1.ContentPlaceholder.Controls[0].FindControl("linkSignOut") as LinkButton;
                    lnkuser1.Text    = "HELLO [Admin]:   " + (string)(Session["USERS"]);
                    lnkuser1.Visible = true;
                    lnkuser2.Visible = true;
                    lnkuser3.Visible = true;

                    Login log = Block1.ContentPlaceholder.Controls[0].FindControl("Login1") as Login;
                    log.Visible = false;
                }
                if (Session["USERS"] == null)
                {
                    LinkButton lnkuser1 = Block1.ContentPlaceholder.Controls[0].FindControl("linkAdmin") as LinkButton;
                    LinkButton lnkuser2 = Block1.ContentPlaceholder.Controls[0].FindControl("linkBack") as LinkButton;
                    LinkButton lnkuser3 = Block1.ContentPlaceholder.Controls[0].FindControl("linkSignOut") as LinkButton;
                    lnkuser1.Visible = false;
                    lnkuser2.Visible = false;
                    lnkuser3.Visible = false;

                    Login log = Block1.ContentPlaceholder.Controls[0].FindControl("Login1") as Login;
                    log.Visible = true;
                }
            }
        }
        catch (Exception)
        {
            //Response.Redirect("Default.aspx");
        }
    }