Mark Fitzpatrick
1/26/2007 3:27:00 PM
Michael,
What is the actual ID of the control. ctlSubDevice is the tagname
suchas <uc1:ctlSubDevice runat="server"... but is this the same as the id
assigned to the control? Often, when a control is dragged onto the designer
it will name the control to match the tagname, but add a 1 such as
ctlSubDevice1. So your tag may look like <uc1:ctlSubDevice
Id="ctlSubDevice1" runat="server"></uc1ctlSubDevice> so the name of the
control is actually ctlSubDevice.
You don't need to do any casting or use findcontrol at all. In the
codebehind just create a protected variable of the same name as the
control's id.
protected NetView.WebUI.ctlSubDevice ctlSubDevice1;
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Michael Lierheimer" <MichaelLierheimer@discussions.microsoft.com> wrote in
message news:1DD8E686-5BF7-4807-830E-43148A6775A6@microsoft.com...
> Hallo.
>
> After migration from ASP1.0 to ASP 2.0 I have the following problem. The
> migrated code does not compile. I get an error: "Cannot implicitly convert
> type 'NetView.WebUI.ctlSubDevice' to 'ASP.distributor_ctlsubdevice_ascx'.
> An explicit conversion exists ...."
>
> The line in the code behind file is:
> ctlSubDevice = (NetView.WebUI.ctlSubDevice)
> this.FindControl("ctlSubDevice");
> This code it worked in ASP.NET 1.0. An analysis of the problem showed that
> the type ot the ctlSubDevice, which is NetView.WebUI.ctlSubDevice, was
> implict convert to ASP.distributor_ctlsubdevice_ascx. So the cast fails.
>
> In the aspx file, the control is registered with:
> <%@ Reference Control="~/distributor/ctlsubdevice.ascx" %>
> <%@ Register TagPrefix="uc1" TagName="ctlSubDevice"
> Src="ctlSubDevice.ascx" %>
>
> Does anybody has a solution for this problem, or did I missed something ;)
>
> Yours
> Michael