place WebUserControl in X, Y location

D

Dave Johnson

i built nested UserControls, and the parent control dynamicly generate
the child contorls, but i have a problem with positioning them on the
control page, how is it done for WebUseControl, i am sure its very
simple and basic Question but as i am new to usercontrols help will be
very appreciated if given multiple ways if there is more than one way.

thanks,


Sharing makes All the Difference
 
D

Daniel TIZON

Hi Dave,
To place a WebUserControls dynamicaly on the page you should :
- place a static Container Control, a <ASP:placeHolder> or a <ASP:panel>
control on the page.
- create an instance of the UserControl by using the LoadControl method
MyUserControl MyUC =
(MyUserControl)Page.LoadControl("WUC/MyUserControl.ascx");
- pass the parameters
MyUC.param1="hello";
- Add the control to the controls collection of your container.
MyPanel.Controls.add(MyUC);

If you want to place the control to x,y coordonates, I advise to use the
Panel as a container and to add Styles
MyPanel.Style.Add("position","absolute");
MyPanel.Style.Add("left","296px");
MyPanel.Style.Add("top","159px");

Hope this helps !
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top