How To Find the Control or Page a User Control is Embedded In
        Posted  
        
            by 
                5arx
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by 5arx
        
        
        
        Published on 2011-01-09T00:22:20Z
        Indexed on 
            2011/01/09
            0:53 UTC
        
        
        Read the original article
        Hit count: 260
        
I've written a web user control which I want to be able to drop into the markup for either aspx pages or other web user controls.
I need my user control to be able to easily and efficiently work out if its inside another user control or an aspx page. My initial idea is to do it recursively with checks on the Parent property - continue looking up the nesting hierarchy until I find either a web form or a user control - but I'm not sure this the best way of going about this.
Can you suggest an easier way?
thanks
5arx
© Stack Overflow or respective owner