all groups > asp.net building controls > july 2005 >
You're in the

asp.net building controls

group:

casting custom classes


casting custom classes Sam
7/26/2005 12:00:00 AM
asp.net building controls:
Namespace system.web.ui
Public Class ReplacableControlCollection
Inherits ControlCollection
End Class
End Namespace
-------------------------------------------------------

Public Shadows ReadOnly Property controls() As
ReplacableControlCollection
Get
Return MyBase.Controls
End Get
End Property
-------------------------------------------------------

Error:
System.InvalidCastException: Unable to cast object of type
'System.Web.UI.ControlCollection' to type
'System.Web.UI.ReplacableControlCollection'.
Line 60: Return MyBase.Controls

-------------------------------------------------------

how do i cast this?
the only thing difference in ReplacableControlCollection from the
original ControlCollection is an added sub "replace()".

Re: casting custom classes sam
7/26/2005 5:32:23 PM
you can't cast down unless the thing actually *is* of that type. what
do you want to do?
Re: casting custom classes Sam
7/27/2005 12:00:00 AM
[quoted text, click to view]

actually i'm trying to create a ReplacableControlCollection and override
the webcontrol.controls with it.

i'm in need of a webcontrol.controls.replace(oldcontrol,newcontrol)
function to replace one control with the other while maintaining the
position in the controls hiarchy.

i don't have the code anymore, because i've solved it a different way
(copyattributes).

AddThis Social Bookmark Button