I agree with Willie. And furthermore, before you post a question be sure
you at least have a BASIC understanding of the .Net Framework.
Why are you trying to cast a Web control to a Form control. I and
apparently Willie also, only checked your syntax not your parameters as we
are not paid to debug your poorly implemented code. Any hobby .Net
programmer knows you can only cast to a type that the object is or has
inherited from. If you took one second out of your busy life to look-up the
Control class and the WebControl class in VS.Net or even MSDN.com instead of
flaming people here that do take time out of their busy lives to help then
maybe you would see the obvious. But that would actually require that you
exercise the few remaining stagnant synapses in your fluid filled globe and
try a little problem solving on your own. So instead you post here and get
frightfully indignant when we have not done all the thinking for you.
Next time solve your own problem. OR be a bit nicer when the community has
left a little work for you to do on your own. After all, it has been
scientifically proven that if you don't use it you will loose it. It is
also true that if you never had it you wont have it unless you go out and
get it.
--Robby
"Willie jan" <un*****@unkown.com> wrote in message
news:41***********************@news.euronet.nl...
if you are irritated, don't blame it on the guys who try to help you in
their coffee time!
"Paul" <pa**@enathan.net> schreef in bericht
news:eX**************@TK2MSFTNGP11.phx.gbl... Neither of these responses work. If you are not certain that something
works, why respond? Many see +'s by these postings and look no further.
If you can run this code and not get any sort of cast exception, then
please respond. Otherwise, please don't waste someone else's time.
DirectCast does not work, nor does Controls.Add(o). Had they tried this
they would know.
"Paul" <pa**@enathan.net> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl... This was posted yesterday. I needed to post again to clarify my problem.
I'm trying to create control from a string in a database:
Dim asm As [Assembly] =
Reflection.Assembly.LoadFrom("C:\WINDOWS\Microsoft .NET\Framework\v1.1.4322\System.Web.dll")
Dim typ As Type = asm.GetType("System.Web.UI.WebControls.TextBox", True,
True)
Dim o As Object = Activator.CreateInstance(typ)
Me.Controls.Add(CType(o, Control))
I get "Specified cast is not valid." with the line of code directly
above. How do I/ Can I cast a type to a control?