When you need to dynamically create a control or use another page's code in your code behind use the reference directive ->
http://msdn.microsoft.com/en-us/library/w70c655a.aspx
Note that you can sometimes get away with only registering the control. But expect to experience some odd compilation problems especially when dependent code is changed...