JG Vimalan's Blog

It is all about coding!

DatePicker using jQuery

I got a task where I need to use datepicker from JQuery in my asp.net application.  The sample source code can be found here: 

http://cid-670f5e7529eed46d.office.live.com/self.aspx/.Public/jQuery/DatePicker.zip

So, when the user clicks on the textbox, the calendar will be displayed. The output will be as shown below,

o

It is really easy to implement and compatible with all browsers.

December 25, 2010 Posted by | ASP.NET, JQuery | 1 Comment

Automated builds created in TFS 2008 did not work in TFS 2010

I faced an issue with the automated builds recently. I created automated builds in tfs 2008 and they worked good. When the project sources are migrated to tfs 2010, all my builds are not work properly in tfs 2010.  Eventhough they succeeded, they did not pick the latest sources rather, an old source is found to be copied to the deployment server. After analysis I found that, in tfs 2010, there is an additional folder created in the path and it is the ‘Agent Id’. So I have updated the source path with the agent id as shown below,

<MyApplicationFiles Include=”D:\Builds\$(BuildAgentID)\$(BuildDefinitionId)\Binaries\debug\_PublishedWebsites\MyProject\**\*.*”/>

 this fixed the issue.

December 24, 2010 Posted by | TFS | Leave a comment

Error loading the changeset comments policy.

I got this error message when I tried to check in my changes into the tfs. I am not violating the check in policy as, I have associated my check in files with a task. This issue happened for me in VS 2010.

 So, to fix this issue, you need to install the TFS 2010 power tools. Please download and install the TFS 2010 power tools from the following location http://visualstudiogallery.msdn.microsoft.com/en-us/c255a1e4-04ba-4f68-8f4e-cd473d6b971f After installing the software, restart the Visual Studio. Now, the check in will work.

December 10, 2010 Posted by | TFS, VS 2010 | 2 Comments

Enable code coverage in VS 2010

Developers add unit tests for every method they write and it ensures quality of the application. To know the lines of code they have covered via unit tests, the code coverage should be enabled. Code coverage tells the developers, the various scenarios (using unit tests) they have covered for testing the methods. To enable code coverage follow the steps below,

a. I assume that, your application has a unit test project and a test list with unit test methods added to it. So, as a first step, in visual studio 2010 ultimate, goto Tests->Edit Test Settings ->Local (local.testsettings) as shown in the image below,

b. Now, the Test Settings dialog will appear. Select ‘Data and Diagnostics’ tab. Select ‘Code Coverage’.  Click on the ‘Configure’ link as shown in the image below,

Now, you will get a dialog window where you can select the assemblies, projects that come under your unit test.

c. Run the unit tests now.Once the test results are displayed, to view the code coverage results, Goto Tests->Windows->Code Coverage Results.

d. The code coverage results will be displayed as shown below,

Normally, code coverage of 85% is considered to be good.

December 9, 2010 Posted by | TFS, VS 2010 | Leave a comment

Using xsd.exe

I got a task where I need to read data from an xml file. So, as a first step, I used the xsd.exe, which comes with visual studio for reading the xml data. the details are given below,

Assume that, you have your xml file as shown below,

Now, to create a class for this xml file, I am going to use the xsd.exe tool. Launch visual studio command prompt and type xsd.exe [xml file path] . An xsd file will be created. Now type xsd.exe [xsd file path] /c. This will create the corresponding class file. See the image below for more details,

Now, the generated class file will be as shown below, this class file can be used in your project while serializing/deserializing the xml file.

//——————————————————————————
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.4952
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//——————————————————————————

using System.Xml.Serialization;

//
// This source code was auto-generated by xsd, Version=2.0.50727.3038.
//
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”, “2.0.50727.3038”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“code”)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace=””, IsNullable=false)]
public partial class Staff {
   
    private string yearField;
   
    private StaffPerson[] personField;
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string Year {
        get {
            return this.yearField;
        }
        set {
            this.yearField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(“Person”, Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public StaffPerson[] Person {
        get {
            return this.personField;
        }
        set {
            this.personField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”, “2.0.50727.3038”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“code”)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class StaffPerson {
   
    private string nameField;
   
    private string ageField;
   
    private string genderField;
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string Name {
        get {
            return this.nameField;
        }
        set {
            this.nameField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string Age {
        get {
            return this.ageField;
        }
        set {
            this.ageField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string Gender {
        get {
            return this.genderField;
        }
        set {
            this.genderField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”, “2.0.50727.3038”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“code”)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace=””, IsNullable=false)]
public partial class NewDataSet {
   
    private Staff[] itemsField;
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(“Staff”)]
    public Staff[] Items {
        get {
            return this.itemsField;
        }
        set {
            this.itemsField = value;
        }
    }
}

December 2, 2010 Posted by | C#.NET | 1 Comment