HTML Content in the sidebar for the 1.2.1 version

May 31, 2008 at 2:02 PM
I would like to put some HTML content in the sidebar. I saw the MWPSK Extension and the sidebar HTML content, but I can't make it working for the version 1.2.1. Someone can help me?

Jul 10, 2008 at 1:32 AM
I had the sidebar working in the older version, but I can not get it to work in 1.2.1.  I need to get this working so I can update to the newer version.  I have seen some talk about making this a 3 section site like DNN.  Is that in the works?

Any help I can get in setting up a sidebar would be appreciated.

Thanks in advance for any help.
Aug 2, 2008 at 4:56 PM
Hi guys!

I was able to get the sidebar html extension running in my extended version of MWPSK. As an addon to TBPrince´s original code I also added the abillity to add HTML above and / or below the default sidebar area. You can set the CSS classes "sidebarTopHTML" and "sidebarBottomHTML" in file "~App_Themes\<Your_Theme>\PageLayout.css" to control it´s position and appearance.

You can download my whole project MWPSKex.#005 (which contains other extensions too) at www.burstmode.de or you can just have a look at these files to see what has to be done (watch out for mark "MWPSKex.#005.I" in the source files):

  ~/App_Code/WepPage.cs
  ~/App_Code/Controls/SidebarControl.cs
  ~/Administration/Navigation.aspx
  ~/Administration/Navigation.aspx.cs

Be sure to edit the global resource file too to define required values for field captions. I used these keys: MWPSKex_adm_SidebarTopHTMLContent, MWPSKex_adm_SidebarBottomHTMLContent

Cheers,
Mark
Aug 3, 2008 at 9:37 AM
Edited Aug 3, 2008 at 9:51 AM
Thanks for the link, I have downloaded the 005 file and when I try to set it up on a local machine it is not allowing me to change the theme.

Do I need to do anything once I have downloaded it ?

Cheers
Dave

Added later:

When I first started this I got a error, but I am guessing it is because I did something wrong, but it works fine now and I really like the thought of each page being able to have a different theme.

Thanks Again
Aug 3, 2008 at 10:30 AM

Hello Dave!

If I got you right then you managed to get it running?

You shouldn´t have any problems since I packed the whole solution in the zip file.

For anybody else interested: To change the theme of a certain page just log in with your admin account, go to page administration, select the desired page from the listbox, wait until the properties show up and then scroll down a bit. There you will find the thumbnail images of all available themes installed. It looks pretty much the same like the overall theme selection everybody will know from the general website setup dialog. Just click one of the thumbnails and that´s it: from then on this page will use the theme you selected while other pages will still go with the default website theme. To select another theme just click again or use the reset button to make this page use the default website theme again. Easy, isn´t it?

Cheers,

Mark

Aug 3, 2008 at 10:51 AM
The only error I have come across is if I change the theme on the homepage and then logout I get the following error

==========================================================
Server Error in '/MWPSK' Application.

Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

Source Error:

Line 48:                 PlaceHolder ctl = new PlaceHolder();
Line 49:                 _template.InstantiateIn(ctl);
Line 50:                 Controls.Add(ctl);
Line 51:             }
Line 52:         }


Source File: c:\Inetpub\wwwroot\MWPSK\App_Code\Controls\TemplatedContent.cs    Line: 50

Stack Trace:

[HttpException (0x80004005): Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.]
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +310
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
   System.Web.UI.Control.AddedControl(Control control, Int32 index) +302
   System.Web.UI.ControlCollection.Add(Control child) +146
   MyWebPagesStarterKit.Controls.TemplatedContent.CreateChildControls() in c:\Inetpub\wwwroot\MWPSK\App_Code\Controls\TemplatedContent.cs:50
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +21
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +292
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +292
   System.Web.UI.Page.FindControl(String id) +39
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +597
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1194

==============================================================================================
Aug 3, 2008 at 11:29 AM

Well, that´s interesting. Could you please list all steps necessary to reproduce this error?

When you logout are you looking at a page that is accessible to authenticated users? (prior to clicking the logout button)

Aug 3, 2008 at 12:24 PM

Ok, this should work:

in file ~/App_Code/Controls/TemplatedContent.cs change method CreateChildControls() to look like this: 

 

 

protected override void CreateChildControls()
{
    
if (_template != null)
    {
        
PlaceHolder ctl = new PlaceHolder();
        _template.InstantiateIn(ctl);
        
try
        
{
            Controls.Add(ctl);
        }
        
catch
        
{
            ctl.EnableViewState =
false;
            Controls.Add(ctl);
        }
    }
}

 

Using logout button will try to load page you last worked with. If this is the same page you changed theme right before then loading of the old viewstate (which belonged to the page showing up with it´s former theme) will fail. Actually in that case there isn´t any valid viewstate available because for the new theme there isn´t any (valid) pre-post data.

Thank you for your error report! 

Aug 4, 2008 at 10:38 AM
Thanks it work great now, it has even got rid of the problems I was having with putting stuff in the side bar.

Thanks Again


Sep 2, 2008 at 6:24 AM
Hi all, it's a little difficult to actually understand where this HTML in sidebar issue is at. I read all the entries on the extensions page and even downloaded the earlier zipped file but was not brave enough to actually place those older files over the newer version 1.2.1 in fact I can't figure out if that was ever the intention. The bottom line is, as a user of 1.2.1 for a couple of months, with 6 actual working websites, I am now at the same point that others arrived at, which is I would like to place 'other' things on the sidebar and the 2 hours of reading everything on this Codeplex site that I could find, has not made it clearer. It is obvious that earlier it was discussed and that zip file supplied, but it also seems that nothing has been done since then, and the latest version 1.2.1 which is my first version, works expertly in every area but does not have the extensions that people had access to earlier. I know you want to remain backward compatible, but can someone just give me the easy explanation of what I need to do i.e. supply a link, to what I need to download and then upload to get this HTML functionality in the sidebar happing on my currently installed and working 1.2.1 websites. Thanks heaps even if you attempt to answer this with even just a guess :-)

Regards
Ron
Sep 2, 2008 at 8:11 AM
Hi Ron,

maybe you wanna have a look here: http://burstmode.de/BlogSearch.aspx?tag=MWPSKex.%23005
(look at the older post in particular)

There you will find a brief enumeration of the files that have to be changed to get a sidebar-HTML extension running. Additionally you can download the MWPSKex package (newest one I recommend) from the download page at www.burstmode.de and use a tool like WinMerge to compare these files to those of the default MWPSK 1.2.1 release. This will show you exactly where to modify the files and what has to be done.

Cheers,
Mark
Sep 2, 2008 at 8:17 AM
Edited Sep 2, 2008 at 9:37 AM
Thanks Mark, I visited that website a month or so ago and he has done a lot to it in that time, it is far more detailed now, okay I'm sure I'll struggle through it now, with this much help, thanks for pointing me in the right direction. BTW, HTML in the sidebar is one thing, is there anyone out there cleaning up other types of code that will probably break it like JavaScript for example?

Thanks again Mark, much appreciated.

Update:

I am having a little bit of an issue trying to get this working. I uploaded the 5 main files and got an error mentioning "MWPSKex_adm_SidebarTopHTMLContent"

I don't understand what I have to do with these two files (SidebarTop & SidebarBottom), actually I can't even find them :-(

The 5 files I uploaded are:

~/App_Code/WepPage.cs
~/App_Code/Controls/SidebarControl.cs
~/Administration/Navigation.aspx
~/Administration/Navigation.aspx.cs
~/App_GlobalResources/StringsRes.resx

I also don't understand they mean by You´ll also have to extend file ~/App_GlobalResources/StringsRes.resx. Does that just mean upload your new one? I don't understand the term extend.

Sorry to ask so many questions, but it is the only way I will learn.

Thank you very much, again :-)

Sep 2, 2008 at 10:28 AM
Ron,

the issues are related to each other:

File ~/App_GlobalResources/StringsRes.resx is a "resource file". In particular this is the default resource file that (in the case of MWPSK) contains string resources in English language. You will find a whole bunch of resx files in the same directory. These contain the corresponding string resources for different languages.

The sidebar-HTML addons included in MWPSKex will enable you to supply html content to be displayed above and/or below the default sidebar container (that´s the obvious part ;). Somewhere you must be able to edit this html content: it is done in the page administration in that case (Navigation.aspx). Compared to the default MWPSK V1.2.1 there are two additional HTML-Editor controls (FCKEditor) in the page administration view. One is for the html to be placed above - the other one is for the html to be placed below the sidebar container.

To point out what these HTML Editor controls are used for, each of them is labeled with a field caption. Example:
Top HTML: [Editor Control]
Bottom HTML: [Editor Control]

"Top HTML" and "Bottom HTML" are field captions. [Editor Control] is an instance of FCKEditor where you actually edit the HTML you wanna see above/below the sidebar on that page.

Since MWPSK by default is multi-language enabled, one should not simply type "Top HTML" in the Navigation.aspx page. This would only be fine for English speakin admins. Instead you make MWPSK use a string resource from a resource file (StringsRes.resx for example).

In file ~/Administration/Navigation.aspx of the MWPSKex package you will find this line:
<asp:Localize ID="Localize8" runat="server" Text="<%$ Resources:stringsRes, MWPSKex_adm_SidebarTopHTMLContent%>"></asp:Localize>

This will display a localized label that holds the caption for the HTML Editor that´s being used to supply the HTML for the upper area. A unique (language independant) key "MWPSKex_adm_SidebarTopHTMLContent" is used as an index into the resource file (StringsRes.resx or any other language version). At runtime the actual text-value is retrieved from the resource file and it gets displayed on the page.

So what does it mean: "MWPSKex_adm_SidebarTopHTMLContent" is not a file. (this is why you can´t find it ;). Instead it is a key in the resource file(s). You must take care to supply an entry in the resource file for this key. (and also for the second one which is "MWPSKex_adm_SidebarBottomHTMLContent"). Try to open file ~/App_GlobalResources/StringsRes.resx with Visual Studio or any other resource editor. You will see many language dependant values defined there. Just make sure that you supply values for the new keys needed by MWPSKex.

Double check that at least in file ~/App_GlobalResources/StringsRes.resx there are entries for keys "MWPSKex_adm_SidebarTopHTMLContent" and "MWPSKex_adm_SidebarBottomHTMLContent". They are included in the download version of this file. If they are not found at runtime (like in your case) you will get an error when trying to display the page administration page. Also try to unload the web-application or restart iis to prevent any caching issues.

One more remark for the MWPSKex-packages in general: Be careful when updating your files. These packages might contain more modifications than you are actually out for. The start-page of www.burstmode.de shows a small table where you can see what modifications are included in a special release of MWPSKex. Newer releases contain ALL modifications of prior versions. So be careful when updating your files: use a tool like WinMerge to compare the files to YOUR version of that file and identify REQUIRED changes - this way stripping out other MWPSKex modifications that you won´t need.
It´s easier for people who can use the MWPSKex packages out of the box. But sometimes this is not possible due to other modifications they have done to their sites - only way in that case is to update files step by step like you tried to do. Again: In that case you´ll have to compare the files to only get what you actually need and want.

Hope you´ll succeed now!

ATB
Mark
Sep 4, 2008 at 8:21 AM
Edited Sep 9, 2008 at 1:17 PM
Thanks Mark, fantastic explanation.

UPDATE: In a once only and flawed workaround, I embedded something directly into the skin.skin file in the relevant theme, and this works on a once only, but of course doesn't let the user interact at all, like is meant to happen in the SidebarHTML extension.

So after some modifications on the #005 files I got this:
Line 46:             if (page != null)
Line 47:             {
Line 48: if (page.SidebarTopHTMLContent.Trim() != string.Empty)Line 49:                 {
Line 50:                     HtmlGenericControl divTopHTML = new HtmlGenericControl("div");

So back to the drawing board, downloaded again, made sure the files were there, checked the relevant code and uploaded. It finaly worked, so that's a big yahooo!

Next Question: It's only just started working but I have noticed something which I hope was more an issue with the computer or the server and not the actual code. I made a test page and then typed 'This is an example of text' in both the top and bottom sections and it worked 100%, it's a wonder you never heard me yelling and punching the air with my fists. Then however when I tried to color, centre or add formating whilst in the 'Source' mode, it kept breaking telling me it was a possible security breach, I forget the exact wording, it was something like this is a possible threat or something similar to that. 

Can anyone else confirm that it is not very robust or was it just me, can other users tell me exactly what thay have actually got working in the sidebar extensions, please state wether or not they were using both the top and bottom sections at the same time or just one. Has any user got any similar stories of not being able to do much other than very simple text?

If I am alone, and everyone else is using it as a powerful feature, can anyone shed any possible light on my initial shaky experience?

TIA
Ron