Retrieve the control parameters while item context is not available

If you would like to retrieve the control parameters while item context is not available.you can use following code


Sitecore.Data.Database db = Sitecore.Data.Database.GetDatabase("database name");
DeviceItem di = DeviceItem.ResolveDevice(db);

Item item = db.GetItem("Pass the Item ID to retrieve it from database");
Sitecore.Layouts.RenderingReference[] rendering = item.Visualization.GetRenderings(di, true);
Sitecore.Layouts.RenderingReference rendItem = rendering.FirstOrDefault(rend => rend.RenderingItem.InnerItem.Paths.FullPath == "compare with control name for which you would like to retrieve parameters");
System.Collections.Specialized.NameValueCollection parameterCollection = Sitecore.Web.WebUtil.ParseUrlParameters(rendItem.Settings.Parameters);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s