by Stephen Horsfield
31. January 2008 08:53
UPDATED: 16-MAY-2008
Overview
How can you get the PageData object for a page when the current user doesn't have access. It took me a while to find out, but you can just read on...
Context
I have been implementing a redirect facility. Only editors and administrators are allowed access to the page and everyone else is redirected according to a property on the page. The ACL on the page does not give Read access to the Everyone group. How can I get the property?
Solution
The easy solution is to use EPiServer 5. Then you can use the GetPage method of the DataFactory class to get a page, ...
[More]
by Brad
31. January 2008 08:42
Its good practice to separate out code that can be re-used into its own class library which can easy be referenced by other projects. Until now any resources such as images/JavaScript files that I'd created I needed to remember to copy to each web site that used the dll, ensuring that I created the correct directory structure so the paths would be correct. Then it dawned on me that you must be able to embed these files into the dll itself. Here's the steps I used to embed an image file for a AjaxControlTookit Calendar Extender that I was using in a custom server control (the same principle can...
[More]
by Stephen Horsfield
28. January 2008 11:18
Overview
Having added Flash content support to a website, I was getting this message in Internet Explorer 6. Internet Explorer 7 and FireFox both worked without any problems. I knew about the issue of Active Content and Internet Explorer 7, but I didn't know what was causing this problem in IE6.
Solution
It turns out that the message is caused by exactly the same behaviour that causes the infamous "click here to use this control" message in Internet Explorer 7. See this article:
Activating ActiveX Controls (Microsoft MSDN)
I was already using a script to generate the <objec...
[More]
by Stephen Horsfield
28. January 2008 09:00
Overview
I have configured a number of different Linux distributions on Virtual Server 2005, but SUSE Linux 10.3 was a non-starter...
The problem
Booting from a SUSE Linux 10.3 ISO (downloaded from http://www.opensuse.org) wouldn't get past the driver loading section. I tried all the usual options such as the brokenmodules option and the noacpi option, but to no avail.
The solution
In the end, I decided to try an earlier version, this time SUSE Linux 10.1 from Novell's website. This time it installed without problems. The VM additions 2.0 installed without a hitch, and once I'd reconfi...
[More]
by matt
25. January 2008 10:12
Overview I reckon that I have probably seen the same LINQ demo as just about everyone else in the world. You know, the one where you get a list of all of the processes running on the server and print them out to the console as follows: var processes = from activeProcesses in Process.GetProcesses()
select new { Name = activeProcesses.ProcessName, ProcessId = activeProcesses.Id };
foreach (var row in processes) Console.WriteLine(row.ToString());
Console.ReadLine();
Well, I tired to use the same principle to iterate through a custom collection for an idea I was ...
[More]
by Stephen Horsfield
25. January 2008 07:23
Overview
When you are using the (very helpful) UpdatePanel, the browser doesn't keep track of the asynchronous postbacks. This means that when the user clicks the back button in the browser, they go to the navigation prior to the last full postback.
How can you resolve this?
Solution
You can solve this by programming the browser, but it is even easier with two alternative server control solutions:
ASP.NET Futures: the History server control and the Sys.Application client object. See ASP.NET Futures (July 2007): Managing Browser History and Back Button Support in ASP.NET AJAX
...
[More]
by Brad
24. January 2008 14:02
Unfortunately the following code will fail if the file in question is ReadOnly:
File.Delete(path);
So I'd always recommend using the following (especially when Visual Studio keeps annoying checking in files that it shouldn't concern itself with!!)
//Check the file actually exists
if (File.Exists(path))
{
//If its readonly set it back to normal //Need to "AND" it as it can also be archive, hidden etc
if ( (File.GetAttributes(path) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
File.SetAttributes(path, FileAttributes.Normal);
//Delete the file...
[More]
1dfc0b48-a1fc-4060-9f76-31fb44cd630f|0|.0
Tags:
C#
by Brad
24. January 2008 13:52
If you want to display the size of a file to the user simply doing the following will result in the size of the file in bytes: new FileInfo(PathToMyFile).Length
However that's fairly useless in today's world of bigger and bigger files so along comes this neat bit of code:
public static string GetFileSizeAsString(long size)
{
double s = size;
string[] format = new string[] { "{0} bytes", "{0} KB", "{0} MB", "{0} GB", "{0} TB", "{0} PB", "{0} EB", "{0} ZB","{0} YB" };
int i = 0;
while (i < format.Length-1 && s >= 1024)
{
s = (100 *...
[More]
a2039a61-9e5c-4ac3-99d8-333a6fd01733|0|.0
Tags:
C#
by Stephen Horsfield
24. January 2008 11:23
Overview
On a Page Type, you can create a property for a web link to a page. This page might be part of the CMS, or it might be on a different site. How can you find out how to render it?
Process
First, you need to get the PropertyData for the property. It might not have a value, but even if it does, the value is just an internal reference to the the page, for example "/templates/MyTemplate.aspx?id=1076". Not very helpful, is it?
Here's a quick method that you can use to return a PageData if the property references a CMS page, or a string with the URL otherwise. You'll still need to c...
[More]
by Stephen Horsfield
24. January 2008 11:11
Overview
Another example of using the API to help with development. This time reordering many properties quickly.
Process and caveats
In EPiServer 4.6, this process doesn't work quite as well as it should. This can result in interesting behaviour of properties not displaying in the editor in the same order as in the administration of the Page Type. Also, some changes don't seem to get saved. I've done my best to get round these issues, but if you've got any suggestions, please post the comments.
So, how do I do it? As before, I'm hosting the code on a very simple ASP.NET page. It use...
[More]
by Brad
23. January 2008 21:53
UpdatePanels work fine with almost all controls, one control that it does 'break' however is FileUpload. If you try and upload a file it will seem to work - but if you check FileUpload.HasFile it will always return false. Rubbish if you've got an UpdatePanel in your MasterPage! However there is a solution, in fact it's not the UpdatePanel that breaks it, but the asynchronous PostBack instead. So a neat trick is to register the button you're using to cause the upload to use a normal PostBack. This can be done as follows: this.ScriptManager.RegisterPostBackControl(btnUpload);
Then when ...
[More]
by Dominic Zukiewicz
23. January 2008 14:25
A simple question.
The bool values are true or false. Easy yes?
How many bytes does it occupy? 4 bytes? 2 bytes? 1 byte?
The actual answer is 1 byte, which you may expect, but the MCTS Application Development Framework exam states that the width of this field is 4 bytes!
So how do we settle it? Even easier.
Console.WriteLine("bool is {0} byte(s) long.", sizeof(bool));
//bool is 1 byte(s) long.
Console.WriteLine("System.Boolean is {0} byte(s) long.", sizeof(System.Boolean));
//System.Boolean is 1 byte(s) long.
95266a63-f76a-4af8-b354-b0b7073dd298|0|.0
Tags:
Framework
by Brad
23. January 2008 13:57
I've just been investigating Microsoft SQL Server 2005 Reporting Services (SSRS) and in a word its great! However this post is about fixing a problem I found when trying to use the ReportBuilder from other computer. When you click "ReportBuilder" in the SSRS web-based UI it will fail with a 401 denied error. By default (for security) the "ReportServer" virtual directory doesn't allow anonymous access, and Microsoft's ClickOnce technology doesn't seem to allow you to provide a username and password - fairly limited I think you'll agree. Anyway on to the solution... if you give anonymous acces...
[More]
by matt
22. January 2008 15:27
Overview For a while now, I have been working on a project that uses a helper class to send any error emails out that may occur during document processing. In order for the helper class to know the recipient and sender for the emails, I have been relying on a custom configuration file which is retrieved from the registry. Now, I inherited this project, and whilst the configuration file was originally used for a great deal of settings, it is now only used for these email addresses. Now - I'm actually running two versions of the same BizTalk Server solution in different applications on the s...
[More]
by Stephen Horsfield
21. January 2008 14:44
Overview
The EPiServer administration tools are pretty good, but every now and then I find that I want a bit more functionality. In this case, I wanted to duplicate new properties across multiple page types, create new properties based on a template and also change existing properties to have unique values for each language. This would have been tedious by hand, but the EPiServer API has everything I needed.
Basic preparation
You don't need to do anything special to access the EPiServer APIs. The easiest option is to create new, standard ASP.NET pages in the admin folder, so that an admi...
[More]
by Stephen Horsfield
18. January 2008 15:53
Overview
This should be easy, but easy it is not. I'm using an EPiServer 4.6 site for this one, so things might've improved in more recent versions, but this caused me a lot of trial and error. I hope this post saves you the hassle.
Context
I've got a Selected/Unselected property set on a Page Type, and I want to search for pages with this property checked. I also want to take account of publishing dates and I've got another date property to check too.
The EPiServer Selected/Unselected property type returns True when selected and Null when it is not. This causes some problems because b...
[More]
by Stephen Horsfield
18. January 2008 14:15
Overview
Using EPiServer, you may use the FindPagesWithCriteria method to retrieve a list of pages based on certain properties, but the helpfully enumerated conditions may be confusing. After all, with a binary inequality operator it is quite important to know the order of the expressions...
Context
You use PropertyCriteria objects to set the criteria for a search and you can use the Condition property to determine the operator. Suppose you selected the GreaterThan operator:
IF --PROPERTY-- > --VALUE-- THEN
But is it actually:
IF --VALUE-- > --PROPERTY-- THEN
The two operations ...
[More]
by Stephen Horsfield
18. January 2008 10:47
Overview
I've been importing a live EPiServer site into a development environment for further work. Normally, this works without problem, but this time I've been getting a POST error, but nothing informative. What's happening?
Solution
A quick look at the event logs on the IIS server quickly identifies the problem: the file exceeds the upload limit. Of course this is less likely to happen in a normal development run, but once there is a fair amount of data it fails. If I hadn't spotted the error in the event log, I might have been stuck for some time.
The default ASP.NET upload limit i...
[More]
by Brad
18. January 2008 10:39
I've just come back to do a "Phase II" of an old EPiServer 4.61 project and was having issue's with none of the child pages working, or even the CSS being loaded in the CMS area. I decided to investigate the style sheet error in the admin area - it was looking for /util/styles/system.css but if I looked in the file system such a file didn't exist... hmm! Then I realised it must be a virtual path and remembered that pre version 5 EPiServer used a custom error page to return virtual files and to do its friendly URL re-writing. So I looked in IIS and bingo there was the problem.... IIS was using ...
[More]
965456a9-113d-4d97-91e0-a7a0c1eaccc9|0|.0
Tags:
EPiServer
by Brad
17. January 2008 14:39
I seem to spend my whole life re-licensing EPiServer sites during development, then again when it gets moved to stage and finally production. Each time I go to EPiServer's site and can never find a simple link to generate a licence and always end up having to go the download area, re-register my details blah blah blah. Anyway here's the link I should have been using - and it's now firmly bookmarked!! http://license.ep.se/public/
8200044b-b98f-4a5a-a175-f708bcd5cff0|0|.0
Tags:
EPiServer