Loadcontrol with parameters

C

Carl Wright

Hi

I'm having this major issue loading a usercontrol at runtime using the
overload on Loadcontrol(type,object). Here's the code in the aspx
code-behind file

Dim myControl As New Control
Dim strCtlPath As String = "~/includes/pinned/NewConsumerReviews.ascx"
Dim objParams(0) As Object
objParams(0) = 1
myControl = LoadControl(strCtlPath)
PlaceHolder1.Controls.Add(LoadControl(myControl.GetType, objParams))

and the user control constructors look like this:

Partial Class Includes_Pinned_NewConsumerReviews
Inherits System.Web.UI.UserControl
Sub New()
MyBase.New()
End Sub
Sub New(ByVal x As Integer)
MyBase.New()
End Sub
<FUNCTIONS>
End Class
The error i'm getting is:

Server Error in '/www.compare-online.co.uk' Application.


Constructor on type 'ASP.includes_pinned_newconsumerreviews_ascx' not found.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Constructor on type
'ASP.includes_pinned_newconsumerreviews_ascx' not found.

Source Error:

Line 69:
Line 70: myControl = LoadControl(strCtlPath)
Line 71: PlaceHolder1.Controls.Add(LoadControl(myControl.GetType,
objParams))
Line 72:
Line 73:


Source File: C:\Solutions\Compare
Online\CompareOnline.Web\compare-online.co.uk\MasterPages\1\Base.master.vb
Line: 71

Stack Trace:

[MissingMethodException: Constructor on type
'ASP.includes_pinned_newconsumerreviews_ascx' not found.]
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder
binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
+1036
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes) +114
System.Web.UI.TemplateControl.LoadControl(IWebObjectFactory
objectFactory, VirtualPath virtualPath, Type t, Object[] parameters) +329
System.Web.UI.TemplateControl.LoadControl(Type t, Object[] parameters)
+13
MasterPages_1_Base.SetPinnedContent() in C:\Solutions\Compare
Online\CompareOnline.Web\compare-online.co.uk\MasterPages\1\Base.master.vb:71
MasterPages_1_Base.Page_Load(Object sender, EventArgs e) in
C:\Solutions\Compare
Online\CompareOnline.Web\compare-online.co.uk\MasterPages\1\Base.master.vb:20
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061







Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.42
Thanks for any help
Carl
 

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

Top