Friday, May 20, 2011

Generate Microsoft standard documents (CHM or HxS) for .NET application

Generate Microsoft standard documents (CHM or HxS) for .NET application
While developing any application developers used to write XML comment on the methods and classes, Using these comments we can easily generate document for .NET application but that will give you XML file, but let say you want to generate CHM or HxS build then Microsoft provide good tool for this Sandcastle This is free tool available in Microsoft site.
Overview
Sandcastle produces accurate, MSDN style, comprehensive documentation by reflecting over the source assemblies and optionally integrating XML Documentation Comments. Sandcastle has the following key features:
·         Works with or without authored comments
·         Supports Generics and .NET Framework 2.0
·         Sandcastle has 2 main components (MrefBuilder and Build Assembler)
·         MrefBuilder generates reflection xml file for Build Assembler
·         Build Assembler includes syntax generation, transformation..etc
·         Sandcastle is used internally to build .Net Framework documentation
System Requirements
Supported Operating Systems:
Windows Server 2003; Windows Vista; Windows XP Service Pack 2, Window 7
Required Software:

Friday, May 06, 2011

Find item from Dropdown, when dropdown binds with Objects like List, Dictionary etc.

Find item from Dropdown, when dropdown binds with Objects like List<T>, Dictionary etc.
When your dropdown bind with List<Object> then you cannot find value from the dropdown list in simple way like we used to do in classic asp.net application
cboLanguage.SelectedIndex = cboLanguage.Items.IndexOf("10");
See in details below
Let's say you have one object called "Language"
public class Languages
{
    public string Code { get; set; }
    public string Name { get; set; }
}

And you are binding your Dropdown from this object List<Languages> like

  List<Languages> lngs = new List<Languages>();

  Languages lng = new Languages();
  lng.Code = "10";
  lng.Name = "Ritesh";
  lngs.Add(lng);

----
---- etc.

Binding dropdown with this List of Objects

cboLanguage.ItemSource = Lngs;

Now if you want to find value on the dropdown and set the index then it will be different approach NOT simple like

Wrong:   cboLanguage.SelectedIndex = cboLanguage.Items.IndexOf("10");


You have to select the complete object from the List<Languages> and then set the selected index for the dropdown

Right:

var item = lngs.Where(ip => ip.Code == "10").FirstOrDefault();

if (item != null)
{
   cboLanguage.SelectedIndex = cboLanguage.Items.IndexOf(item);
}     

In this way you can set default value for dropdown box.