This project is read-only.
1
Vote

TABLayout.aspx FULL of ERRORS (all reproduced on your test sites as well)

description

Hi,
 
i have noticed several errors occurring when adding a new module. here is how to reproduce it:
1 - Adding new tab : click Admin > add new tab (the first time you click the link, the error "Object reference not set to an instance of an object." happens, go to previous page and try again, it might work. the click that produced the error might have created the new tab.
2 - Renaming a tab : this might cause the same error. trying again works. not sure how to if the changes get saved on apply changes and an error happens. sometimes, it does, sometimes it does not.
3 - editing a module on a tab. causes "Object reference not set to an instance of an object." if (_listbox.SelectedIndex != -1) . _istbox is null.
4 - moving a module from a container to an other (ie: center to right or left ) causes if the same error the sourcebox in sourceBox.SelectedIndex != -1 is null.
....
looking at the objects in the debugger it appears that the function such as ListBox _listbox = (ListBox) Page.FindControl(pane); is returning null instead of finding and returning the control or object. is this a .Net bug ?

comments

scharada wrote Aug 5, 2008 at 1:26 PM

sorry guys , I Was too fast in posting a bug. in fact it is an error but the solution was available:
1 - Why it happens : When you apply a master page, that master page has a ContentPlaceHolder control, and your page has only an <asp:Content/> control. This Content control get stripped and discarded and never makes it to the final Page control structure. The contents of the Content control are merged into the ContentPlaceHolder. The result is that the page ends up with only 1 control in its Controls collection: a ContentPlaceHolder from the master page. (Thanks to Jeffrey Palermo for his article http://codebetter.com/blogs/jeffrey.palermo/archive/2004/09/01/23919.aspx)

how to fix :
simply look for the ContentPlaceHolder of your masterpage and use it to findControl (ctlID)
ie:
        //ContentPlaceHolder cph = this.Form.FindControl("maincontent") as ContentPlaceHolder;

        //TextBox ctrlInput = (TextBox)cph.FindControl("mycontrol");

wrote Feb 21, 2013 at 11:50 PM

wrote Jun 18, 2014 at 11:28 AM

wrote Sat at 6:33 AM