Samuel,
PMFJI.
| But it was working in VS2003.
Compiling yes, working (aka executing) we all doubt it!
| Is it possible to make the code to work in
| VS2005 ?
No, for the reasons stated.
Did the Items.Clear method in VS2003 ever get called for a DropDownList?
Have you walked through your code in VS 2003 & verified the code (inside the
If) actually executes?
I suspect in VS2003 you effectively had:
Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)
End Sub
i.e. Although the code compiles in VS 2003, the statement never executed as
ctl could never be a DropDownList!
VS 2005 is much better at catching coding errors such as this, that may
appear correct when you type them, however the code won't actually execute.
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Samuel" <sa****@photoninfotech.com> wrote in message
news:e6**************@tk2msftngp13.phx.gbl...
| But it was working in VS2003. Is it possible to make the code to work in
| VS2005 ?
|
| "Armin Zingler" <az*******@freenet.de> wrote in message
| news:%2****************@TK2MSFTNGP09.phx.gbl...
| > "Samuel" <sa****@photoninfotech.com> schrieb
| >> Hi All,
| >>
| >>
| >>
| >> I am in the process of converting a VS 2003 project to VS 2005
| >> project (VB.NET Class Library).
| >>
| >>
| >>
| >> It gives the error in TypeOf and DirectCast statements. It was
| >> working perfectly under VS2003.
| >>
| >>
| >>
| >> Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)
| >>
| >> If TypeOf ctl Is DropDownList Then
| >>
| >> DirectCast(ctl, DropDownList).Items.Clear()
| >>
| >> End If
| >>
| >> End Sub
| >>
| >>
| >>
| >> 1) The error is Expression of type
| >> 'System.Web.UI.HtmlControls.HtmlControl' can never be of type
| >> 'System.Web.UI.WebControls.DropDownList'.
| >>
| >> 2) Value of type 'System.Web.UI.HtmlControls.HtmlControl' cannot
| >> be converted to 'System.Web.UI.WebControls.DropDownList'
| >>
| >>
| >>
| >> How I can avoid these errors, I tried changing the Option Strict
| >> option to Off. I cannot change the code because the TypeOf and
| >> DirectCast statements are used in more than 200 places.
| >
| > DropDownList is not derived from HtmlControl, thus you can not cast this
| > way. Why do you think you can? A HtmlControl does not have an Items
| > property. The classes derived from HtmlControl are
| >
| > System.Web.UI.HtmlControls.HtmlContainerControl
| > System.Web.UI.HtmlControls.HtmlImage
| > System.Web.UI.HtmlControls.HtmlInputControl
| >
| > ctl can point to one of these objects, but /never/ to a DropDownList
| > object.
| >
| >
| >
| > Armin
|
|