umbraco : How to retrieve drop down value and drop down text in umbraco using c#.

We have some scenario where we want to fetch custom umbraco dropdown list field value and text. For Instance consider situation where you have defined prevalue A, B, C, D in umbraco dropdown list data types and you want to retrieve user selected value from code behind.

See Below Image


demodropdownlist used in demoDropdown document type as property data type.


Now In code Behind file we can retrieve user selected value. In content section it look like


In code behind file we can retrieve user selected value text I mean A, B, C, D or it’s value.

 // Define content node ID in which dropdown data type has been used
 int contentNodeID = 1200;
 Document docDropDown = new Document(contentNodeID);

// Retrive Prevalue of selected value
 int selectedPreVal = Convert.ToInt32(docDropDown.getProperty("dropdownabcd").Value);
 [/sourcecode ]

// Retrive corresponding Text value corrospond to prevalue
 string selectedTextVal = umbraco.library.GetPreValueAsString(selectedPreVal);

Umbraco get member by username by c#.

umbraco Get member by email address

Member memInfo = GetMemberFromEmail("");

Get member from cache in umbraco

Member currentMem = Member.GetCurrentMember();
Member memInfo = GetMemberFromCache(currentMem.Id);

Get member by username in umbraco

Member[] memberList = GetMemberByName("username", false);

Get member by Name instead of user name in umbraco

Member[] memberList = GetMemberByName("name", true);

umbraco Get current member information

Member currentMem = Member.GetCurrentMember();

umbraco Get current member loginName

Member currentMem = Member.GetCurrentMember();
string memeberLoginName = currentMem.LoginName;

umbraco Get current member password

Member currentMem = Member.GetCurrentMember();
string currentMemPassword = currentMem.Password;

umbraco Get current member Id

Member currentMem = Member.GetCurrentMember();
int memberId = currentMem.Id;

I hope it will help 🙂

Umbraco: Remove currently login member from cache by c#.

In Umbraco when we add member to cache at the time of Login:

// Add memeber information to cache.
Member.AddMemberToCache("Nishant", true, new TimeSpan(0, timeOut, 0));

After that we want to remove member from cache for doing this Umbraco provide RemoveMemberFromCache() method. See below working example.

        /// <summary>
        /// Remove Member from cahce
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RemoveMember_Click(object sender, EventArgs e)
            // Get currently login member information
            Member currentLogInMem = Member.GetCurrentMember();
            Member.RemoveMemberFromCache(currentLogInMem .Id);
            Member.ClearMemberFromClient(currentLogInMem .Id);

            // Redirect to Home page
            Response.Redirect("Home Page");

Hope this will help you 🙂

Umbraco: How to attach javascript file in umbraco by c#.

Umbraco provide a great way for attach javascript (.js) file in page mainly in user-control. For attaching js file all you need to do is call umbraco.library.RegisterJavaScriptFile()  method and pass name of js file and path of js file. And Mthod should be called in OnInit

Example  Working Code:

/// <summary>
/// On Init include js files
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
umbraco.library.RegisterJavaScriptFile("MyTest.js", "/scripts/TestApp/MyTest.js");

Hope this will help you 🙂

Umbraco: How to get member login password in plain text or without hashed format by c#.

Basically umbraco keep member user password in hashed format when we retrieve password it give in hashed format which is not human readable format. So point is how we will get member user password in plain text format for doing this you must have to do changes in umbraco web config file. See below format I am using for getting plain text password.

<pre><membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
        <clear />
        <add name="UmbracoMembershipProvider"
			defaultMemberTypeAlias="Another Type"
			passwordFormat="clear" />

C# Code for retrieve password:

     string userPassword = string.Empty;
     string userFullName = string.Empty;
     // Get member by user name
     Member userInfo = null;
     userInfo = Member.GetMemberFromLoginName("");
     // Make sure user exist by given email
     if (userInfo  != null)
         // Get Password
         userPassword = userInfo.Password;
         userFullName = userInfo.Text;

Page keyword: How to let member retrieve login and password, umbraco hashed passwordFormat, Membership user password, get member password in umbraco, retrieve member password, membership provider, User with hashed password in umbraco