Thanks Victor, any ideas on how to get around having to use the user
control at all?

Thanks,

James

-----Original Message-----
From: Victor Garcia Aprea [mailto:[EMAIL PROTECTED]] 
Sent: Monday, April 29, 2002 3:43 PM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Problem w/ Custom Server-Side Control


>>>> <%= this.Parent.ScriptPath %>
You will need to cast Parent to your custom type,

HTH,
-Victor.

> -----Original Message-----
> From: dotnet discussion [mailto:[EMAIL PROTECTED]]
> On Behalf Of James Alexander
> Sent: Monday, April 29, 2002 3:46 PM
> To: [EMAIL PROTECTED]
> Subject: [DOTNET] Problem w/ Custom Server-Side Control
>
>
> I've been attempting to write a server-side web control and have run 
> into a bit of a hurdle. In my web control, I'm overriding the 
> CreateChildControls method to load a user control, like this:
>
> protected override void CreateChildControls ()
> {
>   EditorControl oEditorControl = (EditorControl) 
> Page.LoadControl("editorcontrol.ascx");
>   Controls.Add(oEditorControl);
> }
>
> The reason I'm doing this is because I have a lot of client-side code 
> to generate and it would take a while and be extremely difficult to 
> debug if I where to use the StringBuilder class and pass it to the 
> HTMLTextWriter's write method.
>
> My problem comes in to play when I attempt to access a property of the

> Server Side WebControl from within the User Control. It was my belief 
> that the following snippet should work correctly:
>
> <%= this.Parent.ScriptPath %>
>
> However I get an error saying that ScriptPath cannot be found in the 
> Control scope. Is there something I'm doing wrong? To get around this 
> for the time being, after creating the UserControl by calling 
> Page.LoadControl in the CreateChildControls method, I'm setting a 
> field called parent to the current Server-Side WebControl.
>
> Also, is there a better way for me to separate my presentation logic 
> for my WebControl logic that wouldn't require me to overload the 
> CreateChildControls method?
>
> Thanks,
>
> James
>
> You can read messages from the DOTNET archive, unsubscribe from 
> DOTNET, or subscribe to other DevelopMentor lists at 
> http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to