DCSIMG
Code Better,C# - Gilad Lavian's Blog

Gilad Lavian's Blog

In Development

Browse by Tags

All Tags » Code Better » C# (RSS)
Parsing DateTime formats
A few ways to handle dates in application: try { //Tells the parser to expect a he-IL (culture) date format DateTime dateParse = DateTime .Parse( "28/02/2008" , new CultureInfo ( "he-IL" )); //Tells the parser to expect a date with specific date format DateTime dateParseExact = DateTime .ParseExact( "28/02/2008" , "dd/MM/yyyy" , null ); //Tells the parser to expect a date with specific date format //with exact hours, minutes and seconds DateTime dateTimeParseExact...
LINQ to SQL Classes
One can only wish everybody to speak LINQ! The following solution demonstrate how to query database tables with object relational data classes. For this example you need to download and install the AdventureWorks Database provided by Microsoft. First, create a new console project: Open the "Server Explorer", click on the "Connect to Database" button: Select the Microsoft SQL Server: The next step is to connect to your AdventureWorks Database Server, from the "Add Connection"...
Cool trick with TAB in Visual Studio for auto completing code blocks
I found a cool trick for auto completing some code blocks. Personally, I find it very convenient while i'm in hyperspace speed coding. Its called snippets and its built-in in Visual Studio, and you can create one yoursefe. When you start a new "try" block, after finishing to write "try", immediately press TAB button, it will auto complete to: try { } catch ( Exception ) { throw ; } When you start a new condition block, "if (2 > 1)", and after you add the "else"...
Visual Studio shortcuts keys
You 2 can become a visual studio shotrcut keys GURU ! http://www.dofactory.com/ShortCutKeys/ShortCutKeys.aspx Mister Miagi once said: Rule number one, breathe in and... breathe out ! Rule number two, first learn rule number one...
Ajax.NET Using PageMethods
This is great article for using Ajax.NET PageMethods. By using PageMethods we can call Server Side Code function directly from the client and get some results returned from Server. http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx
ASP.NET OutputCache + OutputCache Profiles
In many projects i built, i used the OutputCache to improve WebSites performance and scalability. OutputCache is a powerful tool for increasing WebSites performance. When using OutputCache, the IIS saves a new version for the specific requested Page in memory. The next time we request the same Page, the IIS will serve us the rendered Page from memory, there for not process the page again. We can also set some conditions for the cache version like: when to cache it, how, and for how long (Duration...
Ajax.NET - Independent updating UpdatePanel control
The problem: When trying to update one UpdatePanel (up1) control next to another UpdatePanel (up2) control, one influences the other and there both triggered. The solution: Adding Attribute UpdateMode="Conditional" to the UpdatePanel control that you don’t wish to update when triggering the next UpdateControl. Now they will not trigger each other. < asp : UpdatePanel ID ="UpdatePanel1" runat ="server"> < ContentTemplate > < table width ="400" cellpadding ="0" border ="1" cellspacing...
Transform an XML to HTML - StringReader
Here is a great way to transform an XML string returned from DB Query to a HTML using DataGrid/List... The xml represent by the StringReader, witch implements a TextReader that reads from a string. Then loaded to DataSet (by ds.ReadXML), and finally binds to the DataGrid. //Supposed this is the text returning from DB... string xml = "<rows><row id='1'><name>Gilad</name><address>Burla</address>" + "<country>Israel</country><...