SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making a custom field in SharePoint 2010. From within the CreateChildControls() function, I would like to refer to the field by the name it has been given in the list. Is this possible?

For instance, if I have an ISBN field based on this example, how can I tell that this column in a list has a DisplayName of "ISBN", while in another list (or even that same list!) there is another ISBN field named "Old ISBN"?

share|improve this question

You normally should not access data in CreateChildControls() because the control itself may not be in a completed state yet. Referencing data should happen in the Load() event as the control lifecycle shows. More detailed info is available here.

Assuming your custom field is based on one of the basic SharePoint controls, you should be able to access the display name of the field simply with this.Title.

share|improve this answer
In the example, a default value is set in CreateChildControls. I want to manipulate the default value as well... Should I move this default value code into OnLoad()? – Nathan DeWitt Feb 29 '12 at 22:37
You may want to set the default value in CreateChildControls to some known bad value like "$DEFAULTVALUE&" and then change it in Load() when you have all of the control data available. The known bad value lets you easily determine if you are dealing with the actual default value or a loaded value. – Dave Wise Feb 29 '12 at 22:49
where does CreateChildControls() fall in the whole page lifecycle? I can't find it listed in either of those links... – Nathan DeWitt Feb 29 '12 at 23:41
It is called when needed, that is, usually prior PreRender() on a GET and prior to Load() on a postback. You can include a call to EnsureChildControls() at the start of your Load() to make sure everything is in place prior to working with the data. – Dave Wise Feb 29 '12 at 23:47

I was able to use this.FieldName to access the static name of the field. I would prefer to use the display name, but the static name will have to do for now.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.