+3  A: 

The simplest solution would probably to keep a reference to your textbox somewhere in your code. Just add a

private TextBox _textbox

at the top of your class and set it to the TextBox you add in your code. Then you can refer to it in your Button_Save event handler.

Rune Grimstad
+1 for the simple answer. Just storing references to dynamically created controls is in most cases the best choice, rather than searching components by name.
OregonGhost
But this is a dynamic form and depending on the object read in, there might be 1 textbox or 50 textboxes, so I can't make a property for each one without knowing how many there will be.
Edward Tanguay
Use a Dictionary<string, TextBox> or even a Dictionary<string, UIElement> then. Use the name of the control as the key and retrieve the control you need.
Rune Grimstad
+2  A: 

You can retrieve it like this:

TextBox tb=(TextBox)Children.First(w=>w.Name=="FirstName");

Not sure what that sp in your code is, but if you really need the 2nd level of controls, you could run a foreach loop over the first level then search by name on the second level.

Blindy
A: 

I can't write comments, so this is as a reply to your comment.

Why not use a

Dictionary<string, TextBox>

as a class property? that way you can keep references to an indefinite number of textbox instances in the class AND access them easily by name in the dictionary?

Zenon
+2  A: 

The answer to this question is you have to use this.RegisterName("FirstName", textBox); which is explained here: http://stackoverflow.com/questions/1755377/why-cant-i-access-a-textbox-by-name-with-findname

Edward Tanguay
RegisterName seems to work as long as you use the FindName method and not FindResource.
Rune Grimstad