Show brackets in Asp.net

when users log into their account, then I show their names, as well as their identifiers that it works, but when I show a notation, it shows that mix means username + notation, for example JOHNMANAGER. The manager is desgination and the same as it happened on my side, but I want the type of designation to be indicated in brackets. here is the code

string desginname = Convert.ToString(loginusers.spdesignname(txt_username.Value, txt_pass.Value));
Session["UserDesignationName"] = desginname;
if (users == 1)
{
     Session["Login2"] = txt_username.Value;
     Session["Login3"] = txt_pass.Value;
     Session["UserDesignationID"] =  desginid;
      //Session["DepartmentID"] = depid; ;
     Session["UserDesignationName"] = desginname;
     Session["UserTypeID"] = users;

     Response.Redirect("alldocuments.aspx");
 }
 else if (users == 2)
 {


     Session["Login2"] = txt_username.Value;
     Session["Login3"] = txt_pass.Value;
     Session["UserDesignationID"] = desginid;
     Session["UserDesignationName"] = desginname;
     Session["UserTypeID"] = users;

     Response.Redirect("alldocuments.aspx");
  }
}           
catch
{
    errrros.Text = "Incorrect User Name or Password";
}

and here is the site master ...

protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
  if (Session["Login2"] != null & Session["UserDesignationName"]!=null) 
            {
               ["UserDesignationID"].ToString();
                WELCOME.Text = Session["Login2"].ToString()  +Session     
             [("UserDesignationName")].ToString();
            }
            lbtnLogout.Visible = Session["Login2"] != null || Session["Login2"] !=    
             null;


        }
    }

and here is the image image

+3
source share
3 answers

Add them to where you create the welcome text:

WELCOME.Text = Session["Login2"].ToString() + " (" +  Session     
         [("UserDesignationName")].ToString() + ")";

or better, use String.Format:

WELCOME.Text = String.Format("{0} ({1})",
                             Session["Login2"].ToString(),
                             Session[("UserDesignationName")].ToString());
+1
source

Try it.

WELCOME.Text = Session["Login2"].ToString()  +
 " (" +  Session["UserDesignationName"].ToString() +")";
0
source

, .

WELCOME.Text = Session["Login2"].ToString() + (Session["UserDesignationName"].ToString()!="" ? " (" + Session["UserDesignationName"].ToString() + ")" : string.Empty) ;
0

All Articles