Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

User controls and LoadControl method

 
 
J055
Guest
Posts: n/a
 
      10-03-2006
Hi

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
Andrew


 
Reply With Quote
 
 
 
 
Luke Zhang [MSFT]
Guest
Posts: n/a
 
      10-05-2006
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.

Sincerely,

Luke Zhang

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



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



Advertisments