The @Reference Directive - Web Dev And Stuff
Wednesday, August 13, 2008 1:01 PM djsolid

The @Reference Directive

When I want to add a user control to a page I use the @Register directive at the top of the page. and the I add the control to the markup. But what if I want to add a user control programmatically but I have no reference of it via the markup? That is where the @Reference directive comes to action.

What's the story?

We have a user control with the name myUserControl.aspx


We add at the top of the page the control we want to programmatically add like this...


And finally the controls is being added to the page like this...


In general, when we declare a control in the page layout we use @Register and when we create the control programmatically we use @Reference.

That's it ...

kick it on

Filed under: , , , ,


No Comments