|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dyamically add user control, along with properties?Hello. I'm trying to dynamically load a user control which I created like this.
Dim sectionTitle1 As Control = Page.LoadControl("~/Controls/SectionTitle.ascx") However, I can't access any of the properties in sectionTitle1. What am I missing? Thank you! -- Steve With the code you havenow , you can only call the properties of the standard
Control class. You need to convert it to your class type to call your properties. Dim MySection as MyControlClassName = CType(sectionTitle1, MyControlClassName) MySection.MyProperty = "whatever" Show quoteHide quote "Steve" <smsinger3@newsgroup.nospam> wrote in message news:00E0451C-72E2-424B-A37C-C0DE08772FAE@microsoft.com... > Hello. I'm trying to dynamically load a user control which I created like > this. > > Dim sectionTitle1 As Control = > Page.LoadControl("~/Controls/SectionTitle.ascx") > > However, I can't access any of the properties in sectionTitle1. What am I > missing? > > Thank you! > > -- > Steve Thanks, Steve, for your reply. That was the first thing I tried, but
intellisense did not pick up the control name so I assumed it wouldn't work. I was wrong. I am also trying this with VS.Net 2005.. maybe that's a bug? Again, thanks for your reply. -- Show quoteHide quoteSteve "Steve C. Orr [MVP, MCSD]" wrote: > With the code you havenow , you can only call the properties of the standard > Control class. > You need to convert it to your class type to call your properties. > > Dim MySection as MyControlClassName = CType(sectionTitle1, > MyControlClassName) > MySection.MyProperty = "whatever" > > -- > I hope this helps, > Steve C. Orr, MCSD, MVP > http://SteveOrr.net > > > > > > "Steve" <smsinger3@newsgroup.nospam> wrote in message > news:00E0451C-72E2-424B-A37C-C0DE08772FAE@microsoft.com... > > Hello. I'm trying to dynamically load a user control which I created like > > this. > > > > Dim sectionTitle1 As Control = > > Page.LoadControl("~/Controls/SectionTitle.ascx") > > > > However, I can't access any of the properties in sectionTitle1. What am I > > missing? > > > > Thank you! > > > > -- > > Steve > > > u do use codebehind?
Show quoteHide quote "Steve" <smsinger3@newsgroup.nospam> schreef in bericht news:E1701096-3E82-48E5-9B2E-6C9738011E76@microsoft.com... > Thanks, Steve, for your reply. That was the first thing I tried, but > intellisense did not pick up the control name so I assumed it wouldn't > work. > I was wrong. I am also trying this with VS.Net 2005.. maybe that's a bug? > > Again, thanks for your reply. > > -- > Steve > > > "Steve C. Orr [MVP, MCSD]" wrote: > >> With the code you havenow , you can only call the properties of the >> standard >> Control class. >> You need to convert it to your class type to call your properties. >> >> Dim MySection as MyControlClassName = CType(sectionTitle1, >> MyControlClassName) >> MySection.MyProperty = "whatever" >> >> -- >> I hope this helps, >> Steve C. Orr, MCSD, MVP >> http://SteveOrr.net >> >> >> >> >> >> "Steve" <smsinger3@newsgroup.nospam> wrote in message >> news:00E0451C-72E2-424B-A37C-C0DE08772FAE@microsoft.com... >> > Hello. I'm trying to dynamically load a user control which I created >> > like >> > this. >> > >> > Dim sectionTitle1 As Control = >> > Page.LoadControl("~/Controls/SectionTitle.ascx") >> > >> > However, I can't access any of the properties in sectionTitle1. What >> > am I >> > missing? >> > >> > Thank you! >> > >> > -- >> > Steve >> >> >> Yes, I did use codbehind and I have no idea why the intellisense did not work.
-- Show quoteHide quoteSteve "Martin" wrote: > u do use codebehind? > > "Steve" <smsinger3@newsgroup.nospam> schreef in bericht > news:E1701096-3E82-48E5-9B2E-6C9738011E76@microsoft.com... > > Thanks, Steve, for your reply. That was the first thing I tried, but > > intellisense did not pick up the control name so I assumed it wouldn't > > work. > > I was wrong. I am also trying this with VS.Net 2005.. maybe that's a bug? > > > > Again, thanks for your reply. > > > > -- > > Steve > > > > > > "Steve C. Orr [MVP, MCSD]" wrote: > > > >> With the code you havenow , you can only call the properties of the > >> standard > >> Control class. > >> You need to convert it to your class type to call your properties. > >> > >> Dim MySection as MyControlClassName = CType(sectionTitle1, > >> MyControlClassName) > >> MySection.MyProperty = "whatever" > >> > >> -- > >> I hope this helps, > >> Steve C. Orr, MCSD, MVP > >> http://SteveOrr.net > >> > >> > >> > >> > >> > >> "Steve" <smsinger3@newsgroup.nospam> wrote in message > >> news:00E0451C-72E2-424B-A37C-C0DE08772FAE@microsoft.com... > >> > Hello. I'm trying to dynamically load a user control which I created > >> > like > >> > this. > >> > > >> > Dim sectionTitle1 As Control = > >> > Page.LoadControl("~/Controls/SectionTitle.ascx") > >> > > >> > However, I can't access any of the properties in sectionTitle1. What > >> > am I > >> > missing? > >> > > >> > Thank you! > >> > > >> > -- > >> > Steve > >> > >> > >> > > >
Other interesting topics
Mystery ASP.NET Error
ImageButton bug Help, DropDown Web Control not Retuning "SelectedValue" AddHandler doesn't seem to work. Blinking Controls Drop down listbox - extra properties, possible? CUSTOMVALIDATOR works but page goes on on FALSE "Google Suggests" and the AJAX .NET Wrapper? CustomValidator VALIDA pero NO FUNCIONA REGEX para Email |
|||||||||||||||||||||||