المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Login usercontrol inside contentplaceholder



C# Programming
07-22-2009, 10:24 AM
I have a default.aspx inheriting a site.master. I placed a login usercontrol inside the default.aspx like so:






To reference functions in the globalLogin, the login usercontrol ctrlLogin.ascx.cs has:
globalLogin login = (globalLogin)this.NamingContainer;
login.whatever()

This generates the error:
System.InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.ContentPlaceHolder' to type 'ProjectName.globalLogin'.

Can anybody help me out and let me know what I am doing wrong? Thanks.