The iFrame field type allows you to create your own GUI for a particular sitecore field. You create a UserControl and reference it with your iFrame field.
Good so far! By default, Sitecore will pass some parameters to your UserControl page (taken right from the sitecore documentation):
- id – The GUID of the item selected by the user.
- la – The language code selected by the user.
- vs – The version number selected by the user.
Super! What if i have multiple iFrame fields on my item that point to the same UserControl though? What’s missing? How about what field am I supposed to be loading from.
This isn’t really a big deal though because the iFrame field type also allows you to specify extra parameters when you set the URL to your UserControl in the field data source. I pass an extra “?field=my-field-name” parameter to the end of my iFrame data source when necessary to avoid this issue. Then in the Page_Load of my UserControl I can use it like so:
if (!IsPostBack)
{
Database db = Factory.GetDatabase("master");
Item myItem = db.GetItem(Request.Params["id"]);
string fieldvalue = myItem[Request.Params["field"]];
// ...
// code to load my control with "fieldvalue"
// ...
}
This is the great help. It worked for me.
Thanks a lot Paul.