Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > User controls and LoadControl method

Thread Tools

User controls and LoadControl method

Posts: n/a

I need to send parameters to a user control contructor. Is this what the
TemplateControl.LoadControl (Type, Object[]) is for? If so can someone show
me how to use it please?

This is my attempt so far but I get a MissingMethodException - Constructor
on type '*' not found. The control would be loaded twice anyway. Hopefully
you can see what I'm trying to achieve.

Control myCtrl = LoadControl("~/Controls/myCtrl.ascx");
PlaceHolder ph = (PlaceHolder)fv.FindControl("ph");
ph.Controls.Add(LoadControl(myCtrl.GetType(), new object[] { myobj }));
ph.Visible = true;

Many thanks

Reply With Quote
Luke Zhang [MSFT]
Posts: n/a
Hello Andrew,

If you need to send parameters to a user control, you may consider created
customized public property for the user control, and set the property right
after you create/load it.


Luke Zhang

Microsoft Online Community Support
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply With Quote

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
LoadControl problem - External Controls lennart ASP .Net 1 04-25-2010 07:51 AM
Executing and rendering user controls via LoadControl and RenderControl Deane ASP .Net Building Controls 0 09-03-2007 08:47 PM
Controls failing when using LoadControl David R ASP .Net 1 01-04-2006 11:34 AM
Is LoadControl (virtualPath) is caching controls in a single request. If so, can i disable it. Umut Tezduyar ASP .Net 10 11-29-2004 07:10 AM
LoadControl() method throws virtual path error when attempting to load user control from subfolder. Jeremy ASP .Net 2 06-24-2004 05:57 AM