Clipboard is a windows object. If you want to use clipboard in your .NET framework console applications you must reference `System.Windows.Forms` and mark your main method with `STAThreadAttribute` attribute. Then you can use this class's methods e.g. Clipboard.SetText("some text to store in the clipboard"); Happy coding.
Enterprise Library 4.1 Data Application Block Integration Exception
if you are getting this exception "The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory' threw an exception." try to reference Microsoft.Practices.ObjectBuilder2.dll Happy coding…
inherit In Child Applications
You can add the <location> element with the “inheritInChildApplications” attribute to the root web.config. This attribute will prevent child applications inherit some specified configuration from the root web.config. The attribute must be placed in the <configuration> section of the web.config. It looks like this: Referance: SectionInformation.InheritInChildApplications Property
Visual Studio 2008 Apply Cutting To Blank Lines
While we are coding we used to delete blank lines with ‘Shift + Del’. Shift + Del shortcut is same as ‘Ctrl + X’. And if you copy something to clipboard before cutting the blank lines, it will be replaced by the blank line. You can change this behaviour with VS 2008 settings. Tools > […]
Switch bit field value with single T-SQL
You can switch the bit field’s value with single update statement by using exclusive or operator. Happy codding… Referance: ^ (Bitwise Exclusive OR) (Transact-SQL)
How to use a method from class in other namespaces at .aspx pages
You can use using statement to inculde different namespaces in you code behind file. But still you can’t call methods from classes that live in other namespaces (Different from you page class namespace) from you content pages (.aspx). To make this work you must use import namespace directive after you page directive. This can be […]
How to clear all HttpContext Cache items?
“HttpContext.Current.Cache” has a metod to remove items one by one with their key names. If you want to remove all items from the cache you can use this little code snippet to achive this task: Happy coding… P.S.: This techique don’t effect the output cached pages.
SiteMapPath Url Querystring problem
When you are using the SiteMapPath control page Urls with the querystrings, pages don't show the control. Because url can't be matched with url in your Web.Sitemap file. To handle this situation, a little web.sitemap file trick is enough. Write the static part of your Url and define the dynamic querystring parameters at "reliantOn" attribute. […]
Timespan and Databases
When you are developing application you may need to store timespan database. (Assuming you are using Sql Server 2005) TimeSpan.TotalSeconds can be used to store. This returns a double. And maps to decimal data type of the sql server. For reverse action to get the time span you can use TimeSpan.FromSeconds method. This will give […]
Converting a List of Inherited Type to a List of Base type
For example you have a base class and a class that inherits it like below. And you have generic list of these types. Then if you want to convert List<B> to List<A> You can use this code block: Happy coding.