Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > LoadControl and CType error

Reply
Thread Tools

LoadControl and CType error

 
 
Justin Dutoit
Guest
Posts: n/a
 
      02-23-2006
Hey. I'm trying to dynamically add User Controls to my page. It appears to
work sometimes, but more often I get the error:
Unable to cast object of type 'ASP.SearchControl' to type
'ASP.SearchControl'.

Dim ctlNextSearch As Control = LoadControl("SearchCB.ascx")
CType(ctlNextSearch, SearchControl).SearchString = SearchItems(Counter)
MyPlaceHolder.Controls.Add(ctlNextSearch)

In the User Control the directive is:
<%@ Control ClassName="SearchControl" Language="VB" %>

I would appreciate any help, thanks.

Tks
Justin Dutoit




 
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
Ctype error in Load control AlecL ASP .Net 4 02-01-2007 04:37 PM
Help- LoadControl and Ctype error Justin Dutoit ASP .Net 1 02-23-2006 02:58 PM
LoadControl and Multiple IDs in UserControls Error Nestor ASP .Net Web Controls 1 11-12-2005 01:58 AM
Strange error from: Dim myState As Object() = CType(savedState, Object()) lisa@starways.net ASP .Net Building Controls 3 04-11-2005 04:56 PM
We are getting deeper and deeper of ctype.h and isspace() ,but no one is telling me ths solution ! Durgesh Sharma C Programming 5 12-21-2004 07:35 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57