Reputation: 14585
When adding controls to a content node via the Presentation -> Layout Details -> Edit, you are allowed to add "Parameters" to the controls. How do you get those parameters from code?
I'm using the forms for web marketers and I want to pass in parameters to the form control and have access to them from custom field controls.
Upvotes: 1
Views: 602
Reputation: 4170
Here is a function to get a parameter:
private string Params(string key)
{
string rawParameters = Attributes["sc_parameters"];
NameValueCollection parameter = WebUtil.ParseUrlParameters(rawParameters);
if (parameter.HasKeys())
return parameter[key];
return "";
}
You need to add it to you sublayout .cs file and it should work.
Upvotes: 2
Reputation: 14585
I was able to do this using
Sitecore.Form.Core.Renderings.FormRender frm = ((Sitecore.Form.Core.Renderings.FormRender)((Sitecore.Form.Web.UI.Controls.BaseControl)this).Form.Parent);
NameValueCollection parameters = Sitecore.Web.WebUtil.ParseUrlParameters(frm.Parameters);
string val = parameters["my_param"];
It's ugly, but it works.
Upvotes: 1