This project is read-only.

Gallery needs Page.EnableViewState = true

Mar 12, 2010 at 8:47 AM

Hi there,

First of all, thanks for a great framework!

I am using build 37499 and modified it slightly so it will work from other places than just the root (that’s another thing that needs to come in place). I am experiencing some problems with the Gallery. It works fine to upload images and view the images when logged in, however when logged out images can’t be viewed separately: when clicking an image it just stays in the same page and shows all images again (in the HTML version). This is due to the fact that the Page.EnableViewState is set to false in PageBaseClass when the user is not logged in:

protected override void OnPreInit(EventArgs e)

      if (!Page.User.Identity.IsAuthenticated)
          Page.EnableViewState = false;

If you comment out this section the Gallery works just fine. However, I don’t know if this will affect other things in the app. I can see in the MWPSK code that this is not done there and wonder why this is done in EPSCMS? Could someone please look into this and make a comment on this issue?


Mar 12, 2010 at 9:58 AM

Hi Magne,

I also experienced some issue's when the app is not running in the root web folder.
From within Visual Studio using cassini for instance.

What did you modify exactly to fix that?

Thanx, Geert

Mar 12, 2010 at 10:49 AM
Edited Mar 12, 2010 at 11:34 AM

Hi Geert,

I also use VS 2008 and Cassini.
Basically you have to look for references that start with a slash, like this example:

<link rel="stylesheet" href="/resources/css/reset.css" type="text/css" media="screen" />

Remove the first slash in the href attribute, like this:

<link rel="stylesheet" href="resources/css/reset.css" type="text/css" media="screen" />

Inside the Administration folder you need to do more. You also need to remove the Administration part:

<link rel="stylesheet" href="/Administration/resources/css/reset.css" type="text/css" media="screen" />

Should become:

<link rel="stylesheet" href="resources/css/reset.css" type="text/css" media="screen" />

You have to do that a lot of places, both for href and for src attributes. It could be a good idea to start with a search and replace for the whole project:

Do tihs first:

Replace href=”/Administration/ with href=”

Replace src=”/Administration/ with src=”

Then do this:

Replace href=”/ with href=”

Replace src=”/ with src=”

For any server controls you should add a ~ in front of the slash, like this ~/ (that means the application root).
Also check for the slash thing in the codebehind files, I remember changing that in CssMenu.cs and AccordianMenu.ascx.cs):

In CssMenu.cs:
string menuScriptUrl = Page.ResolveUrl("~/scripts/menu.js");
Page.ClientScript.RegisterClientScriptInclude("MenuControl", menuScriptUrl);

In AccordianMenu.ascx.cs

I could send you you my code if you want to take a look at it. I also added a new skin where the sidebar menu is on the left and not the right (don’t know why they decided to put it on the right side).


Mar 18, 2010 at 8:06 PM
Edited Mar 18, 2010 at 8:10 PM


The disabled viewstate is to prevent to create this huge viewstate loaded on each page.  Nothing happens when set this to true. Only a huge viewstate will appear on each page. That't why the gallery work ok when logged in.
- Yes the gallery section and several more need this to function, but as you see I'm about to rewrite all section to be independent on viewstate. My latest project is to move everything into ASP.NET MVC to get a more clean output.

The resources path is changed in default.browser below App_Browser folder. I guess if you remove HtmlHead, HtmlMeta and HtmlLink, the website should map all stylesheet etc. from the current location and not from root. You can also locate the Adapter files in Adapters folder. "See below".



  <browser refID="Default">
<!-- Comment this out and you'll have a tilde "~" 

      adapterType="MyWebPagesStarterKit.Adapters.HtmlHeadAdapter" />
      adapterType="MyWebPagesStarterKit.Adapters.HtmlLinkAdapter" />
      adapterType="MyWebPagesStarterKit.Adapters.HtmlMetaAdapter" />


      <adapter controlType="System.Web.UI.WebControls.Menu"
                 adapterType="MyWebPagesStarterKit.Adapters.MenuAdapter" />

      <adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
     adapterType="MyWebPagesStarterKit.Adapters.FormRewriterControlAdapter" />

      <adapter controlType="FreeTextBoxControls.ImageGallery"
      adapterType="MyWebPagesStarterKit.FtbImageGalleryAdapter" />

      <adapter controlType ="System.Web.UI.WebControls.SiteMapPath"
               adapterType ="MyWebPagesStarterKit.Adapters.SiteMapPathAdapter" />