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)
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

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top