Way to change from Username to Display Name?

Last post 08-17-2009, 6:57 AM by kpcrash. 11 replies.
Sort Posts: Previous Next
  •  08-05-2009, 1:10 PM 54520

    Way to change from Username to Display Name?

    We are using Cute Chat within our DNN implementation.  Currently, the username is shown during the chat session but we would like to use the Display Name in DNN that's available to us for the chat session instead.
     
    Is this possible?
     
    Thanks.
  •  08-05-2009, 1:30 PM 54523 in reply to 54520

    Re: Way to change from Username to Display Name?

    Yes. It's possible.
     
    Please open App_Code\DNNChatProvider.vb and change line 84 to:
     
                    user.FullName
                    user.DisplayName
                    user.FirstName
                    user.LastName

    Hope it helps.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-05-2009, 3:57 PM 54526 in reply to 54523

    Re: Way to change from Username to Display Name?

    Line 84 is explicitly this:
                If System.Web.Security.Membership.ValidateUser(loginName, password) Then
    inside this function: Public Overrides Function ValidateUser(ByVal loginName As String, ByVal password As String) As Boolean
     
    Do you think it's in this function: Function GetUserInfo
    and I change nickName = user.Username to nickName = user.DisplayName?
     
    Other functions in this class where this change might make sense:
          Function GetLogonIdentity
          Function FindUserLoginName
     
    Thanks for your help.
  •  08-05-2009, 4:00 PM 54527 in reply to 54526

    Re: Way to change from Username to Display Name?

    Please change nickName = user.Username to nickName = user.DisplayName.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-12-2009, 9:32 AM 54647 in reply to 54527

    Re: Way to change from Username to Display Name?

    Is there an easy way to do this in the Sample Portal provided?
  •  08-12-2009, 11:22 AM 54659 in reply to 54647

    Re: Way to change from Username to Display Name?

    Hi,
     
    In the SampleProvider.cs ,
     
    find the public override bool GetUserInfo(string loginName, ref string nickName)
     
    and change the nickName=loginName;  to
     
    nickName=loginName+"!";
     
    and then compile it and test it.
     
    Regards,
    Terry
     
  •  08-16-2009, 7:59 AM 54719 in reply to 54659

    Re: Way to change from Username to Display Name?

    All that did was add a "!" to the username (expected). 
  •  08-16-2009, 8:05 PM 54722 in reply to 54719

    Re: Way to change from Username to Display Name?

    Nevermind - I fixed it :) Next question in new thread.
  •  08-17-2009, 1:20 AM 54727 in reply to 54722

    Re: Way to change from Username to Display Name?

    Could you throw some light on how you did it.
     
    Cheers!
  •  08-17-2009, 3:41 AM 54732 in reply to 54727

    Re: Way to change from Username to Display Name?

    Hi dhananjaym,
     
    1. Open file 'DNNChatProvider.vb'(App_Code\DNNChatProvider.vb)
     
    2. Find section  nickName = user.Username
     
    3. Change the section above to  nickName = user.DisplayName
     
    Regards,
     
    Ken
  •  08-17-2009, 6:26 AM 54735 in reply to 54732

    Re: Way to change from Username to Display Name?

    Hi,
     
    I am currently using this in GetUserInfo function
     
    nickName = userObj.Screenname;
     
     
    But still in the Web messenger in online friends when I mouse over the contact I can see the username
    alongwith display name.
     
    Regards,
    Dhananjay
     
  •  08-17-2009, 6:57 AM 54736 in reply to 54727

    Re: Way to change from Username to Display Name?

     
    dhananjaym:
    Could you throw some light on how you did it.
     
    Cheers!
     
    Since my issue was within the chatrooms, I wrote a GetUserDiplayName function into the SampleProvider.cs file. 
    public string GetDisplayName(string username)
            {
                SqlConnection conn = this.CreateConnection();
                String tusername = "User:" + username;
                SqlCommand cmd = new SqlCommand("SELECT DisplayName from CuteChat4_User WHERE UserID=@Username", conn);
                SqlParameter paraUsername = cmd.Parameters.Add("@Username", SqlDbType.NVarChar);
                paraUsername.Value = tusername;
                try
                {
                    conn.Open();
                    string tmp = (String)cmd.ExecuteScalar();
                    if (tmp.Length < 5) //in case they've never set a display name, but let "admin" in
                    {
                        return username;
                    }
                    if (tmp.ToLower() != username.ToLower())
                    {
                        return tmp;
                    }
                    else
                    {
                        return username;
                    }
                }
                catch
                {
                    return username;
                }
                finally
                {
                    conn.Close();
                }
            }
View as RSS news feed in XML