| Stefan [MSFT] 2005-06-27, 7:49 am |
| Hi Pablo,
that is not a MCMS problem.
The problem shows up in the line
["application_name"].userControls.sideMenu.displayMenu()
This is not a MCMS object.
Please debug the user control and check what's going on.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
<pablo.coberly@wanadoo.es> wrote in message
news:1119874254.146917.185940@g14g2000cwa.googlegroups.com...
> Hi,
>
> I don't understand this problem, partly because it occurs only on one
> server. The error:
>
> MCMS: Object reference not set to an instance of an object.
>
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> ["application_name"].userControls.sideMenu.displayMenu()
> ["application_name"].userControls.sideMenu.Page_Load(Object sender,
> EventArgs e)
> System.Web.UI.Control.OnLoad(EventArgs e) +67
> System.Web.UI.Control.LoadRecursive() +35
> System.Web.UI.Control.LoadRecursive() +98
> System.Web.UI.Control.LoadRecursive() +98
> System.Web.UI.Page.ProcessRequestMain() +750
>
> Our dev and staging servers do not have this error and this is after
> ensuring that channels, postings, resources, and rights-groups have
> been exported to staging to try to replicate the problem. This error
> seems to have occured over the weekend. No changes were made to the
> code since it was working, and according to site authors there haven't
> been any changes to the channels or postings themselves.
>
> The problem appears to be in the displayMenu method. I would appreciate
> someone's evaluation of the error and subsequent code very much. I
> guess I'm hoping that someone will spot something obvious because I
> just can't see it.
>
> Many thanks,
> P.
>
> Server Error in '/' Application.
>
> Object reference not set to an instance of an object.
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> displayMenu();
> }
>
> #region side menu
>
> string strBaseURL;
> int intMenuSubLevels = 0;
> Channel parChannel = null;
> Posting activePosting;
> private void displayMenu()
> {
> strBaseURL = "example_channel";
>
> //get context
> CmsApplicationContext cmsApp = new CmsApplicationContext();
> CmsHttpContext McmsContext = CmsHttpContext.Current;
>
> //get collection of channels from root channel
> Channel example_channel;
> string path = "/Channels/www.website.com/example_channel";
> example_channel = McmsContext.Searches.GetByPath(path) as Channel;
> ChannelCollection colSubChannels = example_channel.Channels;
> Channel objCurChannel = McmsContext.Channel;
>
>
> activePosting = McmsContext.Posting;
> lblSideMenu.Text ="";
> foreach (Channel activeChan in colSubChannels)
> {
> if (objCurChannel.IsDescendantOf(activeChan) || activeChan ==
> objCurChannel)
> {
>
> hasChildChan(activeChan);
> }
> }
>
> }
>
>
> private void hasChildChan(Channel objChan)
> {
> CmsHttpContext McmsContext = CmsHttpContext.Current;
> Channel objCurChannel = McmsContext.Channel;
> ChannelCollection chanCollection = objChan.Channels;
> string bVisibleInMenu = "true";
> hasChildPostings(objChan.Postings);
> string strColor = "";
> string strMenuClass = "";
> if (chanCollection.Count > 0 )
> {
> lblSideMenu.Text += "<div id='divChanHolder' >";
> intMenuSubLevels++;
> foreach (Channel chItem in chanCollection)
> {
> String strChanItem = chItem.DisplayName;
> // seagull;
> try
> {
> bVisibleInMenu = chItem.CustomProperties["visibleInMenu"].Value;
> }
> catch
> {
> bVisibleInMenu = "true";
> }
>
> if (bVisibleInMenu == "true")
> {
> if (intMenuSubLevels > 1)
> {
> strColor = "#3399CC"; //background color strColor = "#78C241"
> strMenuClass = "subChannels";
> }
> else
> {
> strColor = "#006699"; //background color strColor = "#5DA527";
> strMenuClass = "topChannels";
> }
> //if (objCurChannel == chItem)
> if (objCurChannel.IsDescendantOf(chItem) || chItem ==
> objCurChannel)
> {
> lblSideMenu.Text += "<div
> style='position:relative;background-color:"+ strColor +
> ";height:20px;width:100%;padding-top:3px;text-indent:" + (6 *
> intMenuSubLevels) + "px'><span class='menuActive'><a href='" +
> chItem.Url + "'>" + strChanItem + "</a></span>";
> if(chItem == objCurChannel)
> {
> lblSideMenu.Text += "<div style='position:absolute;left:" +
> (145) + "px;top:-7px;'><img src='../images/trafalgar/nav/seagull.gif'
> alt='' /></div>";
> }
> }
> else
> {
>
> lblSideMenu.Text += "<div
> style='position:relative;background-color:"+ strColor +
> ";height:20px;width:100%;padding-top:3px;text-indent:" + (6 *
> intMenuSubLevels) + "px'><span class='" + strMenuClass + "'><a href='"
> + chItem.Url + "'>" + strChanItem + "</a></span>";
>
> }
> lblSideMenu.Text += "</div>";
> }
> if (objCurChannel.IsDescendantOf(chItem) || chItem ==
> objCurChannel) {
> parChannel = chItem;
> hasChildChan(chItem);
> }
> }
> lblSideMenu.Text += "</div>";
> intMenuSubLevels = 1;
> }
>
> }
>
>
>
> private void hasChildPostings( PostingCollection objChanItem)
> {
> string bVisibleInMenu = "true";
> string strPostingActive = "";
> string strColor = "";
> string strColor2 = "";
> if(objChanItem.Count > 1)
> {
>
> lblSideMenu.Text += "<div id='divPostingHolder'
> style='position:relative;'>";
> foreach (Posting postingItem in objChanItem)
> {
> try
> {
> bVisibleInMenu =
> postingItem.CustomProperties["visibleInMenu"].Value;
> }
> catch
> {
> bVisibleInMenu = "true";
> }
>
> if (bVisibleInMenu == "true")
> {
> if (postingItem.Parent.DefaultPostingName != postingItem.Name)
> {
> String strChanItem = postingItem.DisplayName;
>
> if (postingItem == activePosting)
> {
> strPostingActive = "Active";
> }
> strColor = "#3399CC"; //gap between sub channels
> strColor2 = "#3399CC"; //postings background color
>
> //Check for the base level parent of the current channel
> lblSideMenu.Text += "<div
> style='position:relative;background-color:"+ strColor2
> +";width:100%;text-indent:" + (8 ) + "px;'><span class='postings" +
> strPostingActive + "'><a href='" + postingItem.Url + "'>- " +
> strChanItem + "</a></span></div>";
> }
> }
> //tidy
> strPostingActive = "";
> }
> lblSideMenu.Text += "</div><div
> style='position:relative;padding:3px;bac
kground-color:"+ strColor
> +";'></div>";
>
> }
>
> }
>
|