Dynamically Adding a control to divLeft

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.
1/8/2011 10:02:17 AM
Gravatar
Total Posts 9

Dynamically Adding a control to divLeft

Hi All,

I am trying to add a control to divLeft ...

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.Load += new EventHandler(Page_Load);
TreeView1.SelectedNodeChanged += new EventHandler(TreeView1_SelectedNodeChanged);

}
...
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadSettings();
PopulateLabels();
}
TreeView1 = new TreeView();
PopulateControls();
}

...
...
...

Page.Master.FindControl("divLeft").Visible = true;
Page.Master.FindControl("divLeft").Controls.Add(TreeView1);

When i want to get postback by SelectedNodeChanged event it goes error...


Object reference not set to an instance of an object.

...
Line 256: parent.Controls.Add(c);
 

can any one help about this.

thnks.

1/8/2011 12:38:41 PM
Gravatar
Total Posts 18439

Re: Dynamically Adding a control to divLeft

you should not be adding things to divLeft from code, it will be shown or hidden from the master page code depending on whether content is loaded there. The correct way to load something there is to create a UserControl or SiteModule and install it and add it from the content system, or embed a UserControl inside divLeft in layout.master and set AlwaysShowLeftColumn="true" on <portal:StyleSheetCombiner

you should not be editing any mojoPortal code at all, if you do that you will never be able to upgrade. All custom code should be in your own projects, mojoPortal code should only be used for learning and code examples of how to do common tasks can be found.

To do custom development you need to start with the basics and read the documentation and watch the videos

http://www.mojoportal.com/developerdocs.aspx

http://www.mojoportal.com/hello-world-developer-quick-start.aspx

http://www.mojoportal.com/developertrainingvideos.aspx

Hope it helps,

Joe

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