Help- LoadControl and Ctype error

J

Justin Dutoit

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)
' <<< error here
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top