load .ascx or .aspx in webpart??

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/2/2009 2:25:57 AM
al
Gravatar
Total Posts 7

load .ascx or .aspx in webpart??

Hi,

i want to load a control or a page (.ascx or .aspx) in a webpart, is this posible??

Many regards

6/2/2009 6:03:10 AM
Gravatar
Total Posts 18444

Re: load .ascx or .aspx in webpart??

Its possible to use an .ascx from inside a WebPart but not a .aspx unless you load it inside an iframe. An .ascx would typically be used inside a WebPart that is made as a compiled dll but it is more conventional inside a WebPart that is itself a .ascx.

Hope it helps,

Joe 

6/3/2009 3:48:30 PM
al
Gravatar
Total Posts 7

Re: load .ascx or .aspx in webpart??

how can i do that? I put this in the oninit of  webpart but doesn´t work

this.Page.LoadControl("Example.ascx");

 

Thanks

6/4/2009 6:22:36 AM
Gravatar
Total Posts 18444

Re: load .ascx or .aspx in webpart??

Hi,

Control c = Page.LoadControl("~/Example.ascx");

if(c != null)
{

   this.Controls.Add(c);

}

or load it into a specific <asp:Panel id="pnlFoo" runat="server"

pnlFoo.Controls.Add(c);

Note that ~/ represents the root of the site, so you need the full path of the UserControl relative to the site root.

Hope it helps,

Joe 

You must sign in to post in the forums. This thread is closed to new posts.