bungpeng Posted February 25, 2003 Posted February 25, 2003 How to access properties of "user control" in code-behind? I notice that for web control, vs.net will automatic generate code like: Protected WithEvents WelcomeMsg As System.Web.UI.WebControls.Label But for "user control", there are not. So, how do we access those properties of this "user control"?:confused: Quote
*Gurus* Derek Stone Posted February 25, 2003 *Gurus* Posted February 25, 2003 All depends. Does your usercontrol (.ascx file) inherit from a custom base class, or are the properties declared within the .ascx file itself? Also, how is the usercontrol being loaded, via LoadControl or with a Register directive? Quote Posting Guidelines
bungpeng Posted February 26, 2003 Author Posted February 26, 2003 No inherit from any class, and I load my user control with "register directive". So, what different? and how to solve? Quote
*Gurus* Derek Stone Posted February 27, 2003 *Gurus* Posted February 27, 2003 I've never actually handled UserControls like that, so I'll look into it and get back to you. For now try adding the following line to the codebehind: Protected WithEvents [i]ControlID[/i] As System.Web.UI.UserControl I imagine that'll work unless you're attempting to access programmer defined properties. Quote Posting Guidelines
bungpeng Posted February 28, 2003 Author Posted February 28, 2003 You are right, I attempting to access programmer defined properties Quote
*Gurus* Derek Stone Posted February 28, 2003 *Gurus* Posted February 28, 2003 [mshelp=ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconexposingpageletproperties.htm]This help document[/mshelp] explains the process of implementing programmer defined properties in a UserControl. It might not be exactly what you want, but that's how it's done for the most part. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.