Saturday, September 4, 2010

Sitecore Fetch Squad

Automated crawler fetching websites and blogs from Sitecore content

Archive for the ‘ASP.NET’ Category

typesThatShouldNotBeExpanded

Posted by admin On January - 29 - 2009
After having ran into this myself a few times, and for the 5th time being asked by one of my Sitecore friends; I though I would bring this one up.

Ever had trouble getting your ASP.NET ListView controls to retain ViewState or do standard Paging?

As many of you will know, Sitecore’s web.config is a source of endless configuration fun. Sitecore’s modular nature is basically founded on this configuration - want to switch something around or change how Sitecore works (at your own risk, usually, but that’s ok)? Web.config is the place to go.

Many of the settings are self explanatory and well commented, so working out what they do is fairly straight forward. In some cases, they are not, however.

If you look through, you will find an element named “
typesThatShouldNotBeExpanded”.

In it you will find two entries:

  • System.Web.UI.WebControls.Repeater
  • System.Web.UI.WebControls.DataList

And while I don’t have enough insight into exactly HOW Sitecore ties in to the ASP.NET lifecycle to determine exactly WHY this setting is needed, I can however tell you what happens if you don’t fully control it.

Say you have a control, where you drop in an ASP.NET ListView Control. Or a GridView control. They’ll appear to work fine at first, but you’ll quickly notice that paging and viewstate is acting up a bit on your controls.

The fix for this is easy, and as far as I know this is well known by Sitecore Support. Add your controls to this - almost black magic like - web.config setting, and you’re set :-)

So

Add System.Web.UI.WebControls.ListView, and System.Web.UI.WebControls.GridView to this collection if you find paging, viewstate or other things “that normally works” doesn’t.

I don’t know when this setting was introduced, or even IF there is a reason Sitecore doesn’t include these common controls in the list. Maybe there’s a negative effect on performance or otherwise.

Searching on the web only produces this one link (searching on SDN, two results but similarly without explanation), and that doesn’t tell us anything else than the config setting was apparently introduced in Sitecore 5.3.2 071220.

Into the core

File format problems using Visual Studio to edit Scala code

Posted by admin On January - 21 - 2009

Noticed a weird thing when I tried to use Visual Studio 2008 to edit some scala. First of I created a solution containing a C# class library. Yeh I know this won’t compile but I am just using Visual Studio to edit the files and manage the files. So I have my solution like so:

 

So I went to add a file, so I right clicked on the project and select Add New Item and selected Text File:

So I wrote some simple code and tried to compile it (using the command prompt) and got this error:

So I tried again but this time going through the file menu to create the file, and again select Text File:

I entered the same code and ran it again and this time it worked:

So I thought there must be something weird going on with the encoding,  but when I checked both were UTF-8. So I check the file size, and strangly there is a 3 byte difference, the first file was 129 bytes and the second file is 126 bytes.

I do not know enough about file formats to shed any light on what is causing this, so for now I will just be using the file menu method to add files to my project. Maybe someone who knows more about these things could shed some light on this.

 

 

Mike’s Blog

Add a sublayout programmatically

Posted by admin On December - 29 - 2008
Our code needs to add a sublayout programmatically.

Sitecore Code Snippets

Handle ASPX pages with another extension

Posted by admin On December - 29 - 2008