Friday, June 21, 2013

Problem with converting int to string in Linq to entities

With EF v4 you can use SqlFunctions.StringConvert. There is no overload for int so you need to cast to a double or a decimal. Your code ends up looking like this:
var items = from c in contacts
        select new ListItem
        {
            Value = SqlFunctions.StringConvert((double)c.ContactId),
            Text = c.Name
        };

Saturday, April 27, 2013

MVC 4 Web Api IIS7.5 HTTP web config issues


<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
        
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
</system.webServer>
ref : http://stackoverflow.com/questions/9703090/mvc-4-web-api-iis7-5-http-404-page-not-found
I was struggling with this as well. Fortunately, Steve Michelotti documented a solution that worked for me here.
At the end of the day, I enabled all verbs (verb="*") to the ExtensionlessUrlHandler-Integrated-4.0 handler in my web config.

How to change File and Folder permissions on windows OS using Command Line (CLI)?

The following commands will help to take the ownership of the directory and files:
D:\>takeown /f D:\path\to\directory /r /d y
D:\>icacls D:\path\to\directory /grant administrators:F /t

Thursday, April 18, 2013

jquery click event not firing?


Is this markup added to the DOM asynchronously? You will need to use live in that case:
The fact that you are able to re-run your script block and have it work tells me that for some reason the elements weren't available at the time of binding or the binding was removed at some point. If the elements weren't there at bind-time, you will need to use live (or event delegation, preferably). Otherwise, you need to check your code for something else that would be removing the binding.
Using jQuery 1.7 event delegation:
$(function () {

    $('.play_navigation').on('click', 'a', function (e) {
        console.log('this is the click');
        e.preventDefault();
    });

});
You can also delegate events up to the document if you feel that you would like to bind the event before the document is ready (note that this also causes jQuery to examine every click event to determine if the element matches the appropriate selector):
$(document).on('click', '.play_navigation a', function (e) {
    console.log('this is the click');
    e.preventDefault();
});


ref : http://stackoverflow.com/questions/5540561/jquery-click-event-not-firing

Wednesday, February 20, 2013

Windows Phone toolkit 4 (How to install)

Here is how you can install the Windows Phone 8 version of the 

toolkit 



Windows Phone toolkit provides a collection of controls, extension methods and page animations to help create beautiful and consistent Windows Phone user interfaces and make common progamming tasks easier. Documentation and source are on CodePlex at http://phone.codeplex.com.
NO. 1) To install Windows Phone toolkit, run the following command in the Package Manager Console

PM> Install-Package WPtoolkit

NO. 2) via NuGet in an easy way using only Visual Studio.

Step1. Create a new Widows Phone 8 Application Project in Visual Studio:
image
Step2. If you have not used NuGet before then go to "VisualStudio Tools-> Extentions and Updates.." as demonstrated below:
image
Step3.Go to "Visual Studio Gallery" tab and type "Nuget" in the search box. Next  install "NuGet Package Manager"  as demonstrated below:
image
image image
NOTE: Once the installation has finished, you must restart Visual Studio, in order for the changes to take effect!
image
Step4. After you have installed the NuGet Package Manager just right-click the References folder in your project and from the context menu select the "Manage NuGet Packages.." option:
image
Step5-a. A new window will appear where you can search for a particular package. So just start typing "windows phone toolkit"  in the search box and you should see the "Windows Phone Toolkit " package on top. Next press install.
image
Step5-b: Alternatively you can Installing he "Windows Phone Toolkit " package using the command line:
Just go to View ->Other Windows -> Package Manager Console:
image
Next type the following code in the console:
PM> Install-Package WPtoolkit
Step6. After the installation has finished you should see the following:
image
Step7. That was all. You will notice that your project now references the Windows Phone Toolkit  assemblies and a new Toolkit.Content Model folder has been automatically added to your project. Your project is now set up and  you are ready to start using the Windows Phone Toolkit  in your application..
image
Step8. Later if you want to update to a new  version of  the Windows Phone Toolkit  , you can use the following NuGet command:
PM> Update-Package WPtoolkit
That was all about how to install Windows Phone Toolkit - October 2012 (8.0 SDK) via NuGet.

Tuesday, February 19, 2013

Windows Phone : ShareStatusTask and ShareLinkTask


In this post I am going to talk about ShareLinkTask and ShareStatusTask that come with the Windows Phone Mango update of the developer tools.
Note: ShareLinkTask and ShareStatusTask do not work on the emulator. So you will need real Mango device connected to Facebook,Windows Live, etc. in order to test them.
ShareLinkTask
Basically ShareLinkTask launches a dialog that enables the user to share a link on the social networks like for example Facebook, Windows Live, etc.
To start using it you will need to include the following namespace:
Namespace:  Microsoft.Phone.Tasks 
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)
 
All you need to do in order to this launchers in your application is:
Step1: Create an instance of  ShareLinkTask,
Step2: Set desired propertied: Title, LinkUri, Message.
Step3. Call Show():

ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "WindowsPhoneGeek";
shareLinkTask.LinkUri = new Uri("http://windowsphonegeek.com", UriKind.Absolute);
shareLinkTask.Message = "The ultimate resource for Windows Phone Development.";
shareLinkTask.Show();

ShareStatusTask
Basically  ShareStatusTask launches a dialog that enables the user to share a status message on the social networks (Facebook, Windows Live, etc.).
To start using it you will need to include the following namespace:
Namespace:  Microsoft.Phone.Tasks 
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)
All you need to do in order to this launchers in your application is:
Step1: Create an instance of  ShareStatusTask,
Step2: Set desired propertied: Status.
Step3. Call Show():

ShareStatusTask shareStatusTask = new ShareStatusTask();
shareStatusTask.Status = "Current Status: Developing WP7 apps.";
shareStatusTask.Show();

That was all about using ShareLinkTask and ShareStatusTask in a Windows Phone Mango application. You can find the full source code of the demo here: