<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dot Net Thoughts &#187; C#.Net</title>
	<atom:link href="http://www.dotnetthoughts.net/tag/c-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetthoughts.net</link>
	<description>thoughts about .Net, WPF, Sharepoint, Javascript and more.</description>
	<lastBuildDate>Wed, 28 Jul 2010 09:59:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Dropdownlist FindByText Problem</title>
		<link>http://www.dotnetthoughts.net/2010/07/15/dropdownlist-findbytext-problem/</link>
		<comments>http://www.dotnetthoughts.net/2010/07/15/dropdownlist-findbytext-problem/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 12:35:03 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[FindByText Problem]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=1001</guid>
		<description><![CDATA[Today one of my colleague talked about a simple basic issue with Dropdownlist, the FindByText() method works as case sensitive. Because of this issue, we are getting some exceptions. So I starting looking for alternatives and one way I found it looping the items and compare it. Like the following. this.ddlItems.SelectedIndex = -1; foreach (ListItem [...]]]></description>
			<content:encoded><![CDATA[<p>Today one of my colleague talked about a simple basic issue with Dropdownlist, the FindByText() method works as case sensitive. Because of this issue, we are getting some exceptions. So I starting looking for alternatives and one way I found it looping the items and compare it. Like the following.</p>
<pre class="brush: csharp;">
this.ddlItems.SelectedIndex = -1;
foreach (ListItem item in this.ddlItems.Items)
{
    if (item.Text.Equals(&quot;Item&quot;, StringComparison.CurrentCultureIgnoreCase))
    {
        item.Selected = true;
        break;
    }
}
</pre>
<p>It is a nice option, I rewrote it as an extension method and works fine. Later I thought of wrting more generic FindByTextMethod() and here the extension method.</p>
<pre class="brush: csharp;">
/// &lt;summary&gt;
/// Searches the Collection of ListItem with a ListItem.Text property contains the specified text
/// &lt;/summary&gt;
/// &lt;param name=&quot;items&quot;&gt;&lt;/param&gt;
/// &lt;param name=&quot;text&quot;&gt;The text to search for.&lt;/param&gt;
/// &lt;param name=&quot;stringComparison&quot;&gt;One of the System.StringComparison values.&lt;/param&gt;
/// &lt;returns&gt;ListItem if the collection contains the text, null otherwise.&lt;/returns&gt;
public static ListItem FindByText(this ListItemCollection items,
    string text,
    StringComparison comparisonType)
{
    ListItem result = items.OfType&lt;ListItem&gt;().
        FirstOrDefault(_string =&gt; _string.Text.Equals(text, comparisonType));
    return result;
}
</pre>
<p>And you can use it like this</p>
<pre class="brush: csharp;">
this.ddlItems.Items.FindByText(&quot;Item&quot;, StringComparison.CurrentCultureIgnoreCase).Selected = true;
</pre>
<p>Happy Coding <img src='http://www.dotnetthoughts.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/07/15/dropdownlist-findbytext-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing Print using C#</title>
		<link>http://www.dotnetthoughts.net/2010/07/08/implementing-print-using-c/</link>
		<comments>http://www.dotnetthoughts.net/2010/07/08/implementing-print-using-c/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 20:43:35 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# Printing]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Print]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=989</guid>
		<description><![CDATA[The first assignment I got from my lead in my previous company was to create Print option to the accounting package we were working. The application was developed in VB 6.0. And we were used batch files and command prompt for printing accounting related documents from the application. Few days back one of colleague asked [...]]]></description>
			<content:encoded><![CDATA[<p>The first assignment I got from my lead in my previous company was to create Print option to the accounting package we were working. The application was developed in VB 6.0. And we were used batch files and command prompt for printing accounting related documents from the application. Few days back one of colleague asked how we can print from C#, he was developing an accounting package for his uncle. I said something like we need to use PrintDocument class for that, but I couldn’t give him a sample code. Today I got some free time in Office so I thought about implementing printing from C#. Here is a simple implementation, which displays a Print Dialog, and based on the settings, it will print the contents of the textbox.</p>
<p><del datetime="2010-07-10T13:53:05+00:00">I tried to print the document based on the ForeColor of the TextBox, but it was throwing some error, I couldn’t resolve it</del>Its fixed. <img src='http://www.dotnetthoughts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Source code is pretty self-explanatory. Happy Printing.</p>
<pre class="brush: csharp;">
private int startIndex = 0;
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
    PrintDocument printDocument = new PrintDocument();
    //Print Options dialog.
    using (PrintDialog printDialog = new PrintDialog())
    {
        printDialog.ShowHelp = false;
        printDialog.ShowNetwork = false;
        printDialog.Document = printDocument;
        printDialog.AllowPrintToFile = true;
        //As its a simple text file, disabling the advanced options.
        printDialog.AllowCurrentPage = false;
        printDialog.AllowSelection = false;
        printDialog.AllowSomePages = false;
        //Display XP Style Print Dialog
        printDialog.UseEXDialog = true;
        if (printDialog.ShowDialog(this) == DialogResult.OK)
        {
            //Assigning the Printer settings to the Document.
            printDocument.PrinterSettings = printDialog.PrinterSettings;
            printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);
            //Number of copies
            for (int i = 0; i &lt; printDialog.PrinterSettings.Copies; i++)
            {
                startIndex = 0;
                //Print method call.
                printDocument.Print();
            }
        }
    }
}
</pre>
<p>And here is the Print Page event.</p>
<pre class="brush: csharp;">
protected void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
    //Setting the color as Black.
    Brush brush = Brushes.Black;
    //Setting color dynamically
    //Brush brush = new SolidBrush(this.txtEditor.ForeColor);
    int lineCounter = 0;
    float lineTop = 0;
    //Looping throught each line in the textbox.
    for (int lineIndex = startIndex; lineIndex &lt; this.txtEditor.Lines.Length; lineIndex++)
    {
        string line = this.txtEditor.Lines[lineIndex];
        lineCounter++;
        //Writing the line to the document.
        lineTop = e.MarginBounds.Top + lineCounter * this.txtEditor.Font.Size;
        e.Graphics.DrawString(line,
            this.txtEditor.Font,
            brush,
            e.MarginBounds.Left,
            lineTop);
        //Checking for more pages.
        if (lineTop &gt; e.MarginBounds.Bottom)
        {
            startIndex = lineIndex;
            e.HasMorePages = true;
            return;
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/07/08/implementing-print-using-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Stored Procedures in Entity Framework</title>
		<link>http://www.dotnetthoughts.net/2010/07/08/how-to-use-stored-procedures-in-entity-framework/</link>
		<comments>http://www.dotnetthoughts.net/2010/07/08/how-to-use-stored-procedures-in-entity-framework/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:34:33 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[ASP.Net MVC]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Entity Framewrok]]></category>
		<category><![CDATA[SP]]></category>
		<category><![CDATA[Stored Procedure]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=976</guid>
		<description><![CDATA[In the current project we are using Entity Framework for database operations. Entity Framework comes with Visual Studio SP1, which helps you to map tables / views / procedures as entities in C# / VB Code. You can find more details about EF from here : http://msdn.microsoft.com/en-us/library/bb399572.aspx. In this post I am explaining how to [...]]]></description>
			<content:encoded><![CDATA[<p>In the current project we are using Entity Framework for database operations. Entity Framework comes with Visual Studio SP1, which helps you to map tables / views / procedures as entities in C# / VB Code. You can find more details about EF from here : <a title="Entity Framework Overview" href="http://msdn.microsoft.com/en-us/library/bb399572.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/bb399572.aspx</a>. In this post I am explaining how to use Stored Procedures in Entity Framework.</p>
<ol>
<li>Add the Stored Procedure to the Entity Model Designer using Update Model From Database Option.</li>
<div id="attachment_979" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/07/Add_Procedure.png"><img class="size-full wp-image-979" title="Add Procedure" src="http://www.dotnetthoughts.net/wp-content/uploads/2010/07/Add_Procedure.png" alt="Add Procedure" width="536" height="485" /></a><p class="wp-caption-text">Add Procedure</p></div>
<li>If you are added successfully, you can get the procedure in Model Browser.</li>
<div id="attachment_981" class="wp-caption aligncenter" style="width: 299px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/07/Model_Browser.png"><img class="size-full wp-image-981" title="Model Browser " src="http://www.dotnetthoughts.net/wp-content/uploads/2010/07/Model_Browser.png" alt="Model Browser " width="289" height="341" /></a><p class="wp-caption-text">Model Browser </p></div>
<li>Right click on the Procedure name and select Create Function Import.</li>
<div id="attachment_980" class="wp-caption aligncenter" style="width: 308px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/07/create_fn_import.png"><img class="size-full wp-image-980" title="Create Function Import" src="http://www.dotnetthoughts.net/wp-content/uploads/2010/07/create_fn_import.png" alt="Create Function Import" width="298" height="320" /></a><p class="wp-caption-text">Create Function Import</p></div>
<li>It will popups a Windows with Stored Procedure Name, Function Import Name and Return Type. If the procedure returns nothing, you can choose none. If the procedure is returns single value, like UserId, Number Of Rows etc, then you can choose scalar option, where you need to specify the return type. And if the procedure is returns Table or Number of Rows, you need to choose the last option Entities, which will allow to select entities created in the Model as the Output. Sometimes we need to create a View in the DB and need to import it in the Model, so that we can use the View as the return type entity.  Select the appropriate return type and click Ok. You can use this in code. In this code I am using a View to return the selected users.</li>
</ol>
<div id="attachment_978" class="wp-caption aligncenter" style="width: 399px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/07/Add_Function_Import.png"><img class="size-full wp-image-978" title="Add Function Import dialog" src="http://www.dotnetthoughts.net/wp-content/uploads/2010/07/Add_Function_Import.png" alt="Add Function Import dialog" width="389" height="278" /></a><p class="wp-caption-text">Add Function Import dialog</p></div>
<pre class="brush: csharp;">

using (SampleEntities context = new SampleEntities())
{
/*
* Thanks to Barry Soetoro.
* I was not calling the GetAllUsers function.
List&lt;Users&gt; Users = null;
Users = (from user in context.Users
             select user).ToList();
this.dataGridView1.DataSource = Users;
*/
//Updated Version.
IEnumerable&lt;UsersView&gt; userview = context.GetAllUsers();
this.dataGridView1.DataSource = userview;
}
</pre>
<p>This will display list of Users in the DataGridView. Happy Coding <img src='http://www.dotnetthoughts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/07/08/how-to-use-stored-procedures-in-entity-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Customize SpellCheck in WPF textbox</title>
		<link>http://www.dotnetthoughts.net/2010/06/22/customize-spellcheck-in-wpf-textbox/</link>
		<comments>http://www.dotnetthoughts.net/2010/06/22/customize-spellcheck-in-wpf-textbox/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 08:43:24 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[SpellCheck]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=936</guid>
		<description><![CDATA[While working on a personal project (fleetIt). I worked on Textbox spell check option. I enabled it, it was working fine, until I added a context menu to to the textbox, for custom commands of my application. It was displaying the spelling errors but the suggestions and correction options was not available. Then I tried [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a personal project (fleetIt). I worked on Textbox spell check option. I enabled it, it was working fine, until I added a context menu to to the textbox, for custom commands of my application. It was displaying the spelling errors but the suggestions and correction options was not available. Then I tried to customize the context menu such a way that it can display both my custom options as well as the system default spell check options. Here is a simple implementation, which helps to customize the context menu and display the spell check suggestions options.</p>
<pre class="brush: xml;">
&lt;Window x:Class=&quot;dotnetthoughts.net.MainWindow&quot;
xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:sys=&quot;clr-namespace:System;assembly=System&quot;
Title=&quot;WPF SpellCheck Demo&quot; Height=&quot;350&quot; Width=&quot;525&quot; Loaded=&quot;Window_Loaded&quot;&gt;
&lt;DockPanel&gt;
&lt;TextBox Name=&quot;txtEdit&quot; SpellCheck.IsEnabled=&quot;True&quot;
                AcceptsReturn=&quot;True&quot;
ContextMenuOpening=&quot;txtEdit_ContextMenuOpening&quot;
                VerticalScrollBarVisibility=&quot;Visible&quot;&gt;
&lt;TextBox.ContextMenu&gt;
&lt;ContextMenu Name=&quot;ctxMenu&quot; /&gt;
&lt;/TextBox.ContextMenu&gt;
&lt;/TextBox&gt;
&lt;/DockPanel&gt;
&lt;/Window&gt;
</pre>
<p>And here is the code behind</p>
<pre class="brush: csharp;">
namespace dotnetthoughts.net
{
    using System;
    using System.IO;
using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;

public partial class MainWindow : Window
    {
public MainWindow()
        {
InitializeComponent();
        }

private void txtEdit_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            int index = 0;
this.txtEdit.ContextMenu.Items.Clear(); //Clearing the existing items
            //Getting the spellcheck suggestions.
SpellingError spellingError = this.txtEdit.GetSpellingError(this.txtEdit.CaretIndex);
if (spellingError != null &amp;&amp; spellingError.Suggestions.Count() &gt;= 1)
            {
                //Creating the suggestions menu items.
foreach (string suggestion in spellingError.Suggestions)
                {
MenuItem menuItem = new MenuItem();
                    menuItem.Header = suggestion;
menuItem.FontWeight = FontWeights.Bold;
menuItem.Command = EditingCommands.CorrectSpellingError;
                    menuItem.CommandParameter = suggestion;
menuItem.CommandTarget = this.txtEdit;
this.txtEdit.ContextMenu.Items.Insert(index, menuItem);
                    index++;
                }
Separator seperator = new Separator();
this.txtEdit.ContextMenu.Items.Insert(index, seperator);
                index++;
//Adding the IgnoreAll menu item
MenuItem IgnoreAllMenuItem = new MenuItem();
                IgnoreAllMenuItem.Header = &quot;Ignore All&quot;;
IgnoreAllMenuItem.Command = EditingCommands.IgnoreSpellingError;
IgnoreAllMenuItem.CommandTarget = this.txtEdit;
                this.txtEdit.ContextMenu.Items.Insert(index, IgnoreAllMenuItem);
                index++;
            }
            else
            {
//No Suggestions found, add a disabled NoSuggestions menuitem.
                MenuItem menuItem = new MenuItem();
menuItem.Header = &quot;No Suggestions&quot;;
                menuItem.IsEnabled = false;
this.txtEdit.ContextMenu.Items.Insert(index, menuItem);
                index++;
            }
//.Net 4.0 Supports CustomDictionaries, Option for Adding to dictionary.
int selectionStart = this.txtEdit.GetSpellingErrorStart(this.txtEdit.CaretIndex);
            if (selectionStart &gt;= 0)
            {
                Separator seperator1 = new Separator();
this.txtEdit.ContextMenu.Items.Insert(index, seperator1);
                index++;
MenuItem AddToDictionary = new MenuItem();
                AddToDictionary.Header = &quot;Add to Dictionary&quot;;
                //Getting the word to add
this.txtEdit.SelectionStart = selectionStart;
this.txtEdit.SelectionLength = this.txtEdit.GetSpellingErrorLength(this.txtEdit.CaretIndex);
                //Ignoring the added word.
AddToDictionary.Command = EditingCommands.IgnoreSpellingError;
AddToDictionary.CommandTarget = this.txtEdit;
AddToDictionary.Click += (object o, RoutedEventArgs rea) =&gt;
                {
this.AddToDictionary(this.txtEdit.SelectedText);
                };
this.txtEdit.ContextMenu.Items.Insert(index, AddToDictionary);
                index++;
            }

//Common Edit MenuItems.
            Separator seperator2 = new Separator();
this.txtEdit.ContextMenu.Items.Insert(index, seperator2);
            index++;
            //Cut
MenuItem cutMenuItem = new MenuItem();
cutMenuItem.Command = ApplicationCommands.Cut;
this.txtEdit.ContextMenu.Items.Insert(index, cutMenuItem);
            index++;
            //Copy
MenuItem copyMenuItem = new MenuItem();
copyMenuItem.Command = ApplicationCommands.Copy;
this.txtEdit.ContextMenu.Items.Insert(index, copyMenuItem);
            index++;
            //Paste
MenuItem pasteMenuItem = new MenuItem();
pasteMenuItem.Command = ApplicationCommands.Paste;
this.txtEdit.ContextMenu.Items.Insert(index, pasteMenuItem);
            index++;
            Separator seperator3 = new Separator();
this.txtEdit.ContextMenu.Items.Insert(index, seperator3);
            index++;
            //Delete
MenuItem deleteMenuItem = new MenuItem();
deleteMenuItem.Command = ApplicationCommands.Delete;
            this.txtEdit.ContextMenu.Items.Insert(index, deleteMenuItem);
            index++;
            Separator seperator4 = new Separator();
this.txtEdit.ContextMenu.Items.Insert(index, seperator4);
            index++;
            //Select All
MenuItem selectAllMenuItem = new MenuItem();
selectAllMenuItem.Command = ApplicationCommands.SelectAll;
            this.txtEdit.ContextMenu.Items.Insert(index, selectAllMenuItem);
            index++;
        }
        //Method to Add text to Dictionary
private void AddToDictionary(string entry)
        {
using (StreamWriter streamWriter = new StreamWriter(@&quot;D:\WPF\MyCustomDictionary.lex&quot;, true))
            {
streamWriter.WriteLine(entry);
            }
        }

private void Window_Loaded(object sender, RoutedEventArgs e)
        {
//Assigning custom Dictionary to TextBox
this.txtEdit.SpellCheck.CustomDictionaries.Add(new Uri(@&quot;D:\WPF\MyCustomDictionary.lex&quot;));
        }
    }
}
</pre>
<p>The .Net Framework 4.0 supports CustomDictionaries, which helps to create your own Dictionary.</p>
<pre class="brush: csharp;">
//.Net 4.0 Supports CustomDictionaries, Option for Adding to dictionary.
int selectionStart = this.txtEdit.GetSpellingErrorStart(this.txtEdit.CaretIndex);
if (selectionStart &gt;= 0)
{
    Separator seperator1 = new Separator();
this.txtEdit.ContextMenu.Items.Insert(index, seperator1);
    index++;
MenuItem AddToDictionary = new MenuItem();
    AddToDictionary.Header = &quot;Add to Dictionary&quot;;
    //Getting the word to add
this.txtEdit.SelectionStart = selectionStart;
this.txtEdit.SelectionLength = this.txtEdit.GetSpellingErrorLength(this.txtEdit.CaretIndex);
    //Ignoring the added word.
AddToDictionary.Command = EditingCommands.IgnoreSpellingError;
AddToDictionary.CommandTarget = this.txtEdit;
AddToDictionary.Click += (object o, RoutedEventArgs rea) =&gt;
    {
this.AddToDictionary(this.txtEdit.SelectedText);
    };
this.txtEdit.ContextMenu.Items.Insert(index, AddToDictionary);
    index++;
}
</pre>
<p>Here is the screenshot of Demo Application.</p>
<div id="attachment_938" class="wp-caption aligncenter" style="width: 502px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/06/SpellCheck.png"><img class="size-full wp-image-938" title="WPF Spell Check Demo - Screenshot" src="http://www.dotnetthoughts.net/wp-content/uploads/2010/06/SpellCheck.png" alt="WPF Spell Check Demo - Screenshot" width="492" height="287" /></a><p class="wp-caption-text">WPF Spell Check Demo - Screenshot</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/06/22/customize-spellcheck-in-wpf-textbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Places in FileDialog box</title>
		<link>http://www.dotnetthoughts.net/2010/06/21/custom-places-in-filedialog-box/</link>
		<comments>http://www.dotnetthoughts.net/2010/06/21/custom-places-in-filedialog-box/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 04:06:18 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[FileDialog]]></category>
		<category><![CDATA[VB.Net]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=925</guid>
		<description><![CDATA[If you ever tried to Open a File from Visual Studio, you may notice something like Projects Folder in the Open File Dialog. We can also implement the same functionality in our applications by using CustomPlaces collection property of FileDialog class. The OpenFileDialog and SaveFileDialog classes allow you to add folders to the CustomPlaces collection. [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever tried to Open a File from Visual Studio, you may notice something like Projects Folder in the Open File Dialog.</p>
<div id="attachment_926" class="wp-caption aligncenter" style="width: 209px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/06/openfile_vs2010.png"><img class="size-full wp-image-926" title="Open File Dialog in Visual Studio" src="http://www.dotnetthoughts.net/wp-content/uploads/2010/06/openfile_vs2010.png" alt="Open File Dialog in Visual Studio" width="199" height="398" /></a><p class="wp-caption-text">Open File Dialog in Visual Studio</p></div>
<p>We can also implement the same functionality in our applications by using  CustomPlaces collection property of FileDialog class. The OpenFileDialog and SaveFileDialog classes allow you to add folders to the CustomPlaces collection.</p>
<pre class="brush: csharp;">
openFileDialog.CustomPlaces.Add(@&quot;C:\Users&quot;);
</pre>
<p>You can also specify GUID of Windows Vista known folder. Known Folder GUIDs are not case sensitive and are defined in the KnownFolders.h file in the Windows SDK. If the specified Known Folder is not present on the computer that is running the application, the Known Folder is not shown.</p>
<pre class="brush: csharp;">
openFileDialog.CustomPlaces.Add(@&quot;C:\Users&quot;);
//Desktop Folder
openFileDialog.CustomPlaces.Add(new Guid(&quot;B4BFCC3A-DB2C-424C-B029-7FE99A87C641&quot;));
//Downloads Folder
openFileDialog.CustomPlaces.Add(new Guid(&quot;374DE290-123F-4565-9164-39C4925E467B&quot;));
</pre>
<div id="attachment_929" class="wp-caption aligncenter" style="width: 417px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/06/openfile_custom.png"><img src="http://www.dotnetthoughts.net/wp-content/uploads/2010/06/openfile_custom.png" alt="Open File Dialog with Custom Places " title="Open File Dialog with Custom Places " width="407" height="479" class="size-full wp-image-929" /></a><p class="wp-caption-text">Open File Dialog with Custom Places </p></div>
<p>Note: This feature will not have any effect in Windows XP. Also you must set the AutoUpgradeEnabled to True(default) to enable this feature in Vista or Windows 7.</p>
<p>The following table lists few Windows Vista Known Folders and their associated Guid.  </p>
<ol>
<li>Contacts : 56784854-C6CB-462B-8169-88E350ACB882</li>
<li>ControlPanel : 82A74AEB-AEB4-465C-A014-D097EE346D63</li>
<li>Desktop : B4BFCC3A-DB2C-424C-B029-7FE99A87C641</li>
<li>Documents : FDD39AD0-238F-46AF-ADB4-6C85480369C7</li>
<li>Downloads : 374DE290-123F-4565-9164-39C4925E467B</li>
<li>Favorites : 1777F761-68AD-4D8A-87BD-30B759FA33DD</li>
<li>Fonts : FD228CB7-AE11-4AE3-864C-16F3910AB8FE</li>
<li>Music : 4BD8D571-6D19-48D3-BE97-422220080E43</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/06/21/custom-places-in-filedialog-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net Default button and Master Pages</title>
		<link>http://www.dotnetthoughts.net/2010/06/21/asp-net-default-button-and-master-pages/</link>
		<comments>http://www.dotnetthoughts.net/2010/06/21/asp-net-default-button-and-master-pages/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 07:33:34 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[BackToBasics]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=908</guid>
		<description><![CDATA[Last few days I was(am) busy with one pure ASP.Net application(why its pure because we are not using any 3rd party controls, ajax nothing. Everything is postbacking ). Today I got a weird bug from one of my QC team saying when ever they presses ENTER button, focus is on any textbox, it popups Help [...]]]></description>
			<content:encoded><![CDATA[<p>Last few days I was(am) busy with one pure ASP.Net application(why its pure because we are not using any 3rd party controls, ajax nothing. Everything is postbacking <img src='http://www.dotnetthoughts.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). Today I got a weird bug from one of my QC team saying when ever they presses ENTER button, focus is on any textbox, it popups Help window from our application. In our application, end users can open the Help window, by clicking on some help images icons provided in the application. These images are displayed using ASP Image button controls (If you are using ASP Image controls this problem will not occur, but in our application, we need to disable it some scenarios, so can&#8217;t use ASP Image). After searching I found the issue with the default button property of ASP.Net, which helps us to submit the form using Enter Key. In my page ASP.Net considering the Help image button as default button for the Page. We can set the default button to our submit button using various methods. Set the default button property of the FORM, or create a Panel control over the controls and set the default button property of the Panel.</p>
<pre class="brush: xml;">
&lt;form id=&quot;form1&quot; runat=&quot;server&quot; defaultbutton=&quot;cmdSubmit&quot;&gt;
&lt;asp:Panel runat=&quot;server&quot; ID=&quot;plMain&quot; DefaultButton=&quot;cmdSubmit&quot;&gt;
</pre>
<p>Form tag also supports  &#8220;defaultfocus&#8221; this property allows to focus to control, on Page Load.</p>
<pre class="brush: xml;">
&lt;form id=&quot;form1&quot; runat=&quot;server&quot; defaultbutton=&quot;cmdSubmit&quot; defaultfocus=&quot;txtUser&quot;&gt;
</pre>
<p>If you are using Master Pages, there will be some slight difference because, the Form tag will not be available in the content Pages. It can fix using code behind, using FindControl method.</p>
<pre class="brush: csharp;">
(Page.Master.FindControl(&quot;Form1&quot;) as HtmlForm).DefaultButton = this.cmdSubmit.UniqueID;
</pre>
<p>Also you can do something like this</p>
<pre class="brush: csharp;">
Page.Master.Page.Form.DefaultButton = cmdSubmit.UniqueID;
</pre>
<p>Happy Coding <img src='http://www.dotnetthoughts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/06/21/asp-net-default-button-and-master-pages/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
