Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: 'Specified Cast Is Not Valid' Error!

Reply
Thread Tools

Re: 'Specified Cast Is Not Valid' Error!

 
 
Stefan Landgraf
Guest
Posts: n/a
 
      08-19-2003
you have to cast to the correct type:

View IngView = (TypeOfIngView) (Page.LoadControl("../UserControls/IngView.ascx"))

where TypeOfIngView is the type of your control

Regards
Stefan Landgraf


"John" <(E-Mail Removed)> schrieb im Newsbeitrag news:%(E-Mail Removed)...
> Hi all,
>
> I'm receiving the error in the subject heading when I try to add a user
> control into a placeholder.
>
> The sub this is happening in, serves as a toggle between loading one of two
> different user controls into the placeholder. The source is as follows:
> plcMain.Controls.Clear()
>
> IngView = (Page.LoadControl("../UserControls/IngView.ascx"))
>
> plcMain.Controls.Add(IngView) ----------> Error here
>
> How do I avoid this (and please don't recommend to me to hide the user
> control)?
>
> Regards
> John.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is the result of valid dynamic cast always equal to the result ofcorrespondent static cast? Pavel C++ 7 09-18-2010 11:35 PM
Error: specified cast is not valid. Why not? Alan Silver ASP .Net 5 02-15-2005 08:08 PM
error C2440: 'return' : cannot convert from 'const char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Abhijit Bhadra C++ 2 12-01-2004 04:43 PM
malloc - to cast or not to cast, that is the question... EvilRix C Programming 8 02-14-2004 12:08 PM
to cast or not to cast malloc ? MSG C Programming 38 02-10-2004 03:13 PM



Advertisments