SharePoint DateTimeField control and the order of its properties#

Today, I was building a nice little page layout for SharePoint and wanted to use SharePoint DateTimeField control. Since the field I wanted to edit was DateOnly, I set the corresponding property, leaving me with this code:

<SharePointWebControls:DateTimeField runat="server" id="dtfArticleStartDate" DateOnly="true" FieldName="ArticleStartDate" />

Seems fine to me, but ASP.NET did not like it. Or rather, the control did not like it. I got an ArgumentException with the following StackTrace:

[ArgumentException: FieldName value is not specified.]
Microsoft.SharePoint.WebControls.FieldMetadata.get_Field() +150
Microsoft.SharePoint.WebControls.DateTimeField.CreateChildControls() +310
System.Web.UI.Control.EnsureChildControls() +87
Microsoft.SharePoint.WebControls.DateTimeField.set_DateOnly(Boolean value) +29
ASP.MYNEWSPAGE_ASPX__2072755151.__BuildControldtfArticleStartDate()

FieldName value is not specified?! As you can see in my code above, it is indeed specified. But the stack trace gives us more information: The exception occurs in the compiled ASPX file.

  • ASP.MYNEWSPAGE_ASPX__2072755151.__BuildControldtfArticleStartDate():
    - We are building my DateTimeField control.
  • DateTimeField.set_DateOnly:
    - We are setting the DateOnly property.
  • FieldMetadata.get_Field:
    - Getting the field is where the exception occurs.

Note my ASPX-code again: I first set DateOnly="true" and then FieldName="ArticleStartDate". Oh my god, this can't be true... The solution is very simple: change the order of the attributes/properties:

<SharePointWebControls:DateTimeField runat="server" id="dtfArticleStartDate" FieldName="ArticleStartDate" DateOnly="true" />

Against all good practices, the SharePoint team actually created a direct dependency between two properties. At least the stack trace directly tells you where things go wrong, so the solution is obvious. Nonetheless, I thought, this was worth noting. It actually made me laugh, when I encountered it. Another one of those nice little pitfalls when working with SharePoint :-)

Wednesday, November 19, 2008 5:37:25 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

New FCKEditorProvider for DotNetNuke#
A newer (beta) version of the FCKEditorProvider for DotNetNuke has been made available: http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/127/threadid/247501/scope/posts/Default.aspx

It finally integrates the newest version of FCKeditor, giving you much better styling support and various other features. So far, my tests have been quite positive with the new version.

One thing to note is the bothering "Red title" style, that is configured by default. If you wish to remove it, you can edit the fckconfig.js files located in the provider's "FCKeditor" and "Custom" folders. Just comment out the line that add the style to FCKeditor's custom styles, and you'll be rid of it.

Regards to Mauricio Márquez for his great work on the integration!

Monday, August 11, 2008 4:18:22 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

News concerning TransactionScope and Timeouts#

We finally got a useful response concerning the TransactionScope Timeout problem. Someone else had a similar issue and started a new thread in the Microsoft forums: http://forums.microsoft.com/forums/ShowPost.aspx?PostID=3069149&SiteID=1. The issue has been resolved, but only as of the .NET Framework 3.5. There is a new connection string parameter named "Transaction binding". This is set to "Implicit unbind", which by default causes the described (mis-)behavior. Instead, you must set it to "explicit unbind", so that queries issued after the transaction times out are still considered to be INSIDE the transaction and not in auto-commit mode. You can read the details in the forum post.

Alas, this only solves the problem when using the SqlClient ADO.NET provider. For all other transactive repositories, the issue still exists.

Friday, March 28, 2008 12:43:27 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Outlook 2007 HTML-Mail Guidance#

Microsoft changed the rendering engine in Outlook 2007 to Word's HTML-engine, and it really sucks concerning modern design habits (css-positioning, etc.). So you have to look out for some pitfalls. I found a nice guide for designing HTML-Mails for use in Outlook 2007, which can be found at http://www.duoconsulting.com/downloads/contribute/SevenDesignTipsforOutlook2007.pdf.

Also, Microsoft offers tools to validate HTML files for the Word rendering engine. These can be found at http://www.microsoft.com/downloads/details.aspx?familyid=0b764c08-0f86-431e-8bd5-ef0e9ce26a3a.

So, good luck with your e-mail marketing ;-)

 | 
Wednesday, July 25, 2007 11:12:08 AM (W. Europe Standard Time, UTC+01:00)
Comments [1]  | 

 

Connecting to a SqlExpress User Instance#

If you've ever built an ASP.NET application using a User Instance database, you may have come across the problem, that you would have liked to access the database using the Management Studio or similar programs, but just couldn't find the database, because it is in the user instance and not in the database server itself.

I'd like to issue my thanks to Mike of the Sql Server Express Weblog for publishing how it's done. I looked for hours trying to get the database attached to the regular server, but all that is not neccessary. You can directly connect to the user instance by using a named pipe. The original explanation can be found here: http://blogs.msdn.com/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-instances-in-management-studio.aspx. Below are the required steps in short.

  • Connect to the server normally.
  • Issue a new query:
    SELECT owning_principal_name, instance_pipe_name, heart_beat FROM sys.dm_os_child_instances
  • Locate the user instance you wish to connect to and copy the instance_pipe_name column's value.
  • Open a new server connection and use the copied value as the server name.

And presto, you can access everything as you would in the regular server.

Note: The pipe name is generated, when the user instance is first created. After that, it will always remain the same, so you can store it for later use. Access is only possible, when the user instance is active (see the heart_beat column). If it is not, you must first launch the application that uses it (i.e. the web site).

Wednesday, April 25, 2007 4:41:44 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Create your own .prf file#

When working with several POP3 accounts, it can be a real pain to always have to enter every single account when you reinstall outlook or have to switch profiles or simply have multiple computers. Other mail clients have an option to export account settings, Outlook doesn't. Bummer...

I ran into the Office Resource Kit, which at least helped a bit by enabling me to create a custom .prf-file. The accounts specified in the file can be used to create a new Outlook profile. A set of instructions on how to do this can be found at http://support.microsoft.com/kb/308300. When you've created your .prf file, you can set up your accounts on any machine by simply starting it. Hurray for automation :-)

Wednesday, January 31, 2007 3:46:29 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Outlook in a different language#

When connecting to an exchange account for the first time, it sets up all default folders. This is done using the language of the connecting client, which may result in an unexpected layout. This happened to me, leaving me with english instead of german folders.

This would not have been such a problem, but I wanted to import my structure from a previous account. No problem importing things, but they went into new folders with the german names. Now I had two contact folders, two mailboxes, two calenders, everything was there twice, and the empty ones were the defaults...

At first, I was told, the account would have to be reset completely, wiping out all data already imported. But, actually there is a much simpler way of changing the folder names to the desired language. Simple start the Outlook of your desired langauge from the command line specifying the following parameter:

outlook.exe /resetfoldernames

Presto, everything is in your language. Now importing is a lot more fun because you can actually use the imported data.

Monday, January 29, 2007 3:54:30 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Changing the exchange account to synchronize an Xda neo with#

Today, I got a new Exchange account to replace my existing one. After copying everything, I only had to get my Xda neo to sync with the new account. This did not prove to be that easy, as simply changing the configured account led to interesting errors. Not only would ActiveSync always give me an error, it also produced errors in my PIM's contact list. It would show all contacts for a split second, then only show about half of the contacts. I tried to remove them all, but was only able to remove those shown. The others remained and broke the synchronization process.

So, how do you solve this, you ask. I don't know, if this is the best way, but it was the only one I found and that solved my problems without having to hard-reset my device:

  1. Rename the file 'pim' to anything else and restart your PIM. This will clear all contacts, calendar entries, tasks, etc. If you don't sync all these items, you should probably make a backup first!
  2. Remove the mobile device from the ActiveSync connections
  3. Create a new connection to the PIM and start syncing with the new settings

I realize, this is not very comfortable, but at least it works and leaves the rest of your device intact (i.e. installed programs, customized sounds, etc.).

Monday, January 29, 2007 3:36:30 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

PersistenceMode.InnerDefaultProperty#

While I was building an ASP.NET user control, I ran across the problem, how to serialize a property as the inner text of the Control in the ASPX-Code. I found a nice attribute named PersistenceModeAttribute, that allows you to specify, how a property is supposed to be persisted. Setting it to InnerDefaultProperty or EncodedInnerDefaultProperty should do the trick, I thought.

But, as I had to find out, this is only part of what needs to be done. There are two more Attributes, that control the parsing of a control: ParseChildrenAttribute and PersistChildrenAttribute. When you use InnerDefaultProperty to persist a property, you must add [ParseChildren(true, "<YourPropertyName>")] and [PersistChildren(false)] to your control's class declaration. Otherwise things won't persist.

It took me a while to find this solution, and I found a nice explanation of things here: http://alvinzc.blogspot.com/2006/10/aspnet-basic-of-custom-server-control_25.html.

Alvin did a really nice job of explaining, what the attributes do. So if you want the details, just visit his blog.

 |  |  | 
Thursday, December 21, 2006 11:33:40 AM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

All content © 2009 , Christoph Herold