Home All Groups Group Topic Archive Search About

Dyamically add user control, along with properties?

Author
3 Jun 2005 8:41 PM
Steve
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

Author
3 Jun 2005 11:02 PM
Steve C. Orr [MVP, MCSD]
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





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
Are all your drivers up to date? click for free checkup

Author
4 Jun 2005 2:48 AM
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.

--
Steve


Show quoteHide quote
"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
>
>
>
Author
5 Jun 2005 9:11 PM
Martin
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
>>
>>
>>
Author
6 Jun 2005 1:43 AM
Steve
Yes, I did use codbehind and I have no idea why the intellisense did not work.
--
Steve


Show quoteHide quote
"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
> >>
> >>
> >>
>
>
>

Bookmark and Share