Friday, March 25, 2011

MediaPicker in User Control and Umbraco custom section

I have just completed one of the task, where I am using Umbraco 4.0.* version CMS.
This task involved developing an user control which will be housed in an custom section and this user control should have option of selecting an image from umbraco server.

I looked at around as to how i can incorporate mediapicker control in my custom user control. I tried using the method suggested in this link, but this control doesnt provide any property which can identify the media file, that was selected.

But this posting, which has a post posted by Jeroen solved my issue. This solution utilizes Mediachooser which has a value property, which gets/sets the media file id.

The solution involves, adding the mediachooser to the placeholder onInit event of the control.

When the user control is submitted for saving, on the post-back, the mediachooser.value contains the value of the media file id.

The following statements will fetch the url for a mediachooser with image selected.

var mediaItem = umbraco.cms.businesslogic.media.Media(Convert.ToInt32(mediaChooserControl.Value))
imageurl = mediaItem.getProperty("umbracoFile").Value.ToString();




XMLUtil class in Adobe Flash CS5 and error 1061

Recently I tried to compile older CS4 project with Flash CS5 but was getting error 1061 error.

I looked on the net and found this useful posting which pointed that the error is because of conflict of two XMLUtil classes eventhough both have different namespaces.

When i removed the $(AppConfig)/ActionScript 3.0/libs/ directory within ActionScript export settings, everything seem fine, as it compiled without any errors.

Thanks to deRaab, for this post..

It really saved a lot of time for me..

Facebook Graph API :Authenticating in IFrame Applications

I found this article interesting and useful... for authenticating the IFrame Applications and using Facebook Graph API.

Facebook API for Dot net

This link contains the latest facebook api for dot net...


Why Use Generics

Generics allow you to define type-safe classes without compromising type safety, performance, or productivity.

Generics Benefits

1. Generics in .NET let you reuse code and the effort you put into implementing it. The types and internal data can change without causing code bloat, regardless of whether you are using value or reference types.

2. Reduced Run time errors. In an object-based solutions, compiler cannot detect any errors during compile time in the case of wrong cast operation, as every type in .Net is derived from object class. But this will cause run-time error. By using the Generics, this situation can be avoided as compiler checks for type-safety.

3. When using value types, the casting between Object and appropriate value type causes unnecessary boxing and un-boxing operations which incur significant performance penalty. Even when using reference types, the casting between object to the actual type involves some casting cost. These costs can be avoided using generics.