|
 |
aspx thread: Alex or anyone: Beta 1 Bug or Just Me! Can't Add a Control Dynami- cally
Message #1 by Scott Watermasysk <swatermasysk@C...> on Tue, 29 May 2001 20:14:59 -0400
|
|
Good Night All,
I have a user control I would like to add to a page dynamically and set two
public properties.
In the SDK Framework Documentation the following example is given:
Control c1 = LoadControl("MyUserControl.ascx");
((MyUserControl_ascx)c1).BackColor = "beige";
Page.Controls.Add(c1);
I have tried this with my own control "ucContent.ascx" and it works, but I
can not have access to my public properties.
The following works:
Control c1 = LoadControl("ucContent.ascx");
Page.Controls.Add(c1);
However, when I try to access on of the controls public properties
(DefualtSid and DefualtCid) I get an error stating "CS0234: The type or
namespace name 'ucContent_ascx' does not exist in the class or namespace
'ASP.dynamiccontrol_aspx'" (Sample page is called ASP.dynamiccontrol.aspx).
The following does not work:
Control c1 = LoadControl("ucContent.ascx");
((ucContent_ascx)c1).DefualtSid = 1;
Page.Controls.Add(c1)
I have tried many different syntax formats, but nothing seems to work. In
addition, I am copying directly from the SDK, so I would think this would be
no problem.
Second Example:
I also tried to access the properties using c1.DefualtSid = 1;, but I got an
error saying "CS0117: 'System.Web.UI.Control' does not contain a definition
for 'DefualtSid'.
Furthermore, I am sure it is not my control, when I use <%@ Register
TagPrefix = "3A" TagName = "Content" src = "ucContent.ascx" %> and
<3A:Content id = "Content" DefualtSid = "0" DefualtCid = "0" runat
"Server" /> to access and set the defualts I have no problems, it only when
I try to set them dynamically.
Is this a bug in Beta 1? Am I just going Nuts? Why me?
Has anyone gotten this to work? If not, any suggestions.
Finally, I tried to do this at both the Page_Load and Page_Init levels,
although I believe Page_Init is more appropriate.
Thanks again to everyone on this list. Your feedback in the past has been
great.
Regards,
Scott
Message #2 by Chris Goode <chrisg@w...> on Wed, 30 May 2001 11:21:37 +0100
|
|
Hi Scott,
This could be caused by the fact that throughout your code below you've
refered to Defualt - I think it should be spelt Default.
Hope that helps,
Chris
-----Original Message-----
From: Scott Watermasysk
[mailto:swatermasysk@C...]
Sent: 30 May 2001 01:15
To: ASP+
Subject: [aspx] Alex or anyone: Beta 1 Bug or Just Me! Can't Add a
Control Dynami cally
Good Night All,
I have a user control I would like to add to a page dynamically and set
two
public properties.
In the SDK Framework Documentation the following example is given:
Control c1 =3D LoadControl("MyUserControl.ascx");
((MyUserControl_ascx)c1).BackColor =3D "beige";
Page.Controls.Add(c1);
I have tried this with my own control "ucContent.ascx" and it works,
but I
can not have access to my public properties.
The following works:
Control c1 =3D LoadControl("ucContent.ascx");
Page.Controls.Add(c1);
However, when I try to access on of the controls public properties
(DefualtSid and DefualtCid) I get an error stating "CS0234: The type or
namespace name 'ucContent_ascx' does not exist in the class or
namespace
'ASP.dynamiccontrol_aspx'" (Sample page is called
ASP.dynamiccontrol.aspx).
The following does not work:
Control c1 =3D LoadControl("ucContent.ascx");
((ucContent_ascx)c1).DefualtSid =3D 1;
Page.Controls.Add(c1)
I have tried many different syntax formats, but nothing seems to work.
In
addition, I am copying directly from the SDK, so I would think this
would be
no problem.
Second Example:
I also tried to access the properties using c1.DefualtSid =3D 1;, but I
got an
error saying "CS0117: 'System.Web.UI.Control' does not contain a
definition
for 'DefualtSid'.
Furthermore, I am sure it is not my control, when I use <%@ Register
TagPrefix =3D "3A" TagName =3D "Content" src =3D "ucContent.ascx" %>
and
<3A:Content id =3D "Content" DefualtSid =3D "0" DefualtCid =3D "0"
runat =3D
"Server" /> to access and set the defualts I have no problems, it only
when
I try to set them dynamically.
Is this a bug in Beta 1? Am I just going Nuts? Why me?
Has anyone gotten this to work? If not, any suggestions.
Finally, I tried to do this at both the Page_Load and Page_Init levels,
although I believe Page_Init is more appropriate.
Thanks again to everyone on this list. Your feedback in the past has
been
great.
Regards,
Scott
Message #3 by Scott Watermasysk <swatermasysk@C...> on Wed, 30 May 2001 08:08:31 -0400
|
|
Chris,
Being 25 years old, I am definitely a product of the spell-check
generation.
To avoid the certain embarrassment of finding out a piece of code
doesn't
work because I never learned to spell multiple syllable words, I
concocted a
more simple user control example to try before I sent in my message. In
addition, during my testing I copied the public name to make sure it
wasn't
a spelling mistake. Normally I would have said duh...but this time I am
sure
it is not me.
I did receive a reply from Alex, and he said it was likely a bug in
Beta 1
and was checking for a work around.
Thanks,
Scott
-----Original Message-----
From: Chris Goode [mailto:chrisg@w...]
Sent: Wednesday, May 30, 2001 6:22 AM
To: ASP+
Subject: [aspx] RE: Alex or anyone: Beta 1 Bug or Just Me! Can't Add a
Con trol Dynami cally
Hi Scott,
This could be caused by the fact that throughout your code below you've
refered to Defualt - I think it should be spelt Default.
Hope that helps,
Chris
-----Original Message-----
From: Scott Watermasysk
[mailto:swatermasysk@C...]
Sent: 30 May 2001 01:15
To: ASP+
Subject: [aspx] Alex or anyone: Beta 1 Bug or Just Me! Can't Add a
Control Dynami cally
Good Night All,
I have a user control I would like to add to a page dynamically and set
two
public properties.
In the SDK Framework Documentation the following example is given:
Control c1 =3D LoadControl("MyUserControl.ascx");
((MyUserControl_ascx)c1).BackColor =3D "beige";
Page.Controls.Add(c1);
I have tried this with my own control "ucContent.ascx" and it works,
but I
can not have access to my public properties.
The following works:
Control c1 =3D LoadControl("ucContent.ascx");
Page.Controls.Add(c1);
However, when I try to access on of the controls public properties
(DefualtSid and DefualtCid) I get an error stating "CS0234: The type or
namespace name 'ucContent_ascx' does not exist in the class or
namespace
'ASP.dynamiccontrol_aspx'" (Sample page is called
ASP.dynamiccontrol.aspx).
The following does not work:
Control c1 =3D LoadControl("ucContent.ascx");
((ucContent_ascx)c1).DefualtSid =3D 1;
Page.Controls.Add(c1)
I have tried many different syntax formats, but nothing seems to work.
In
addition, I am copying directly from the SDK, so I would think this
would be
no problem.
Second Example:
I also tried to access the properties using c1.DefualtSid =3D 1;, but I
got an
error saying "CS0117: 'System.Web.UI.Control' does not contain a
definition
for 'DefualtSid'.
Furthermore, I am sure it is not my control, when I use <%@ Register
TagPrefix =3D "3A" TagName =3D "Content" src =3D "ucContent.ascx" %>
and
<3A:Content id =3D "Content" DefualtSid =3D "0" DefualtCid =3D "0"
runat =3D
"Server" /> to access and set the defualts I have no problems, it only
when
I try to set them dynamically.
Is this a bug in Beta 1? Am I just going Nuts? Why me?
Has anyone gotten this to work? If not, any suggestions.
Finally, I tried to do this at both the Page_Load and Page_Init levels,
although I believe Page_Init is more appropriate.
Thanks again to everyone on this list. Your feedback in the past has
been
great.
Regards,
Scott
|
|
 |