Showing posts from June, 2010

Microsoft Expression Studio 4 released !!

Microsoft Expression Blend is a user interface design tool developed and sold by Microsoft for creating graphical interfaces for web and desktop applications that blend the features of these two types of applications. It is an interactive, WYSIWYG front-end for designing XAML-based interfaces for Windows Presentation Foundation and Silverlight applications. It is one of the applications in the Microsoft Expression Studio suite.

Expression Blend supports the WPF text engine with advanced OpenType typography and ClearType, vector-based 2D widgets, and 3D widgets with hardware acceleration via DirectX.
create rich web experiences, games, desktop apps, and moredesign apps that use the full power of Silverlighttake your ideas from concept to finished project work effectively with design tools, Expression Blend and Visual StudioYou will find the new version from here:

How to compile C# Application for both 32 bit and 64 bit system?

I have faced this problem when one of my client try to run SMS Suit software in Windows 7 64 bit.Previously it is working perfectly in vista and windows xp 32 bit .After searching online I have found lots of solutions on it now I want to share these with you...

Solution :1

You can edit your visual studio c# project file (.csproj) and put this snippet:
1.<PlatformTarget> x86 </PlatformTarget>


2.<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

Solution :2(Command-line form)
Using CorFlags to set the 32BIT flag on the executable. E.g:
corflags.exe myapp.exe /32BIT+

This will modify your exe, so you might wanna keep a backup just in case. You can also revert the flag using /32BIT- instead of /32BIT+.

Solution :3(Simplest way)
1.Right click your Project, and select Properties.
2.In properties, select the Build tab. Under Platform target, select x86.
3.Hit Ctrl+Shift+S to save all files, right click the Solut…

Looping Through Controls in ASP.NET

In my recent development I have badly needed to read all the controls from page. After searching I have found lots of solution. Now I want share with you one of these solution. In this solution we read all the control from page with out using master page.

**Remember to add namespace  System.Collections.Generic

Code: C#

private static Control FindControlIterative(Control root, string id) { Control ctl = root; LinkedList ctls = new LinkedList(); while (ctl != null) { if (ctl.ID == id) return ctl; foreach (Control child in ctl.Controls) { if (child.ID == id) return child; if (child.HasControls()) ctls.AddLast(child); } ctl = ctls.First.Value; ctls.Remove(ctl); } return null; }

 Code: VB.n…

MS Sql server: How to do multiple rows insert ?

Recently I have faced a problem when insert multiple row insert at single call. After first row insert then problem arise from  second row insert. After goggling I have found a solution : it need to clear parameter after each row insert. I want to share that example with you:

Code :C#
// Arranging Data in an Array.
const int no_of_values = 2;
int[] val1 = new int[no_of_values];
int[] val2 = new int[no_of_values];
val1[0] = val1;
val2[0] = val2;
val1[1] = val11;
val2[1] = val22;
// Do the inserts using Parameterized queries.
SqlCeCommand command = Connection.CreateCommand();
command.CommandText = "Insert INTO [Table] (col1, col2) Values (...val1, ...val2)";
for (int i = 0; i < no_of_values; i++)
command.Parameters.Clear(); //it needs to clear parameter after each row inserted.
command.Parameters.Add("...val1", val1[ i ]);
command.Parameters.Add("...val2", val2[ i ]);

I have fixed…

String Formatting in C#

NumbersBasic number formatting specifiers:
SpecifierTypeFormat Output (Passed Double 1.42)Output (Passed Int -12400)cCurrency{0:c}$1.42-$12,400dDecimal (Whole number){0:d}System.FormatException-12400eScientific{0:e}1.420000e+000-1.240000e+004fFixed point{0:f}1.42-12400.00gGeneral{0:g}1.42-12400nNumber with commas for thousands{0:n}1.42-12,400rRound trippable{0:r}1.42System.FormatExceptionxHexadecimal{0:x4}System.FormatExceptioncf90
Custom number formatting:
SpecifierTypeExample Output (Passed Double 1500.42)Note0Zero placeholder{0:00.0000}1500.4200Pads with zeroes.#Digit placeholder{0:(#).##}(1500).42.Decimal point{0:0.0}1500.4,Thousand separator{0:0,0}1,500Must be between two zeroes.,.Number scaling{0:0,.}2Comma adjacent to Period scales by 1000.%Percent{0:0%}150042%Multiplies by 100, adds % sign.eExponent placeholder{0:00e+0}15e+2Many exponent formats available.;Group separatorsee below
The group separator is especially useful for formatting currency values which require that ne…

Deprecated HTML elements /Bad Tag

There are several HTML elements and attributes that have now been declared deprecated by the World Wide Web Consortium (the organization that sets HTML standards).

'Deprecated' means that the elements no longer serve a purpose and have been replaced by other methods, mostly involving cascading stylesheets (CSS). Although it is recommended that web browsers continue to support them, eventually they will become obsolete.

Here lists all the deprecated elements and attributes of HTML 4..
 The FONT and BASEFONT tags The CENTER tag and ALIGN attributeThe U, S and STRIKE elementsThe BACKGROUND and BGCOLOR attributeThe BORDER attributeThe TEXT, LINK, ALINK and VLINK attributesThe HPSACE and VSPACE attributesThe LANGUAGE attributeThe CLEAR attributeThe WIDTH and HEIGHT attributesThe TYPE attribute for listsThe START and VALUE attributes for listsThe COMPACT attribute for listsThe APPLET elementThe DIR and MENU elementsThe ISINDEX elementThe NOSHADE and SIZE attributes for HRThe NOWRAP …

How to get File size in ASP.NET/C#

In forum I have got this question many times like this, "How to get File size" or "How to get File Length". For this today I want to share with you how to get the file size in Its very simple but helpful...


Add namespace:
Using System.IO;

string sMyFileName = "~/photos/test.jpg";

FileInfo finfo = new FileInfo(Server.MapPath(sMyFileName ));
long FileInBytes = finfo.Length;
long FileInKB = finfo.Length / 1024;
long FileInMB = FileInKB /1024;

Response.Write("File Size: " + FileInBytes.ToString() +
" bytes (" + FileInMB.ToString() + " MB)");

Windows 7 : C# Error:'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine


Today I have faced this error when try to use MS Access database from SMS software. After goggling I have found the solution in ...
MSDN forum


The behavior you described is expected. If your application runs in 64-bit mode, all of the components it uses must also be 64-bit. There is no 64-bit Jet OLE DB Provider, so you get the message described. You would receive a similar error when trying to connect to a database using OLE DB or ODBC if there is no 64-bit version of the specified OLE DB provider or ODBC driver.
This problem only occurs in applications that run in 64-bit mode. Compiling the application so it runs only in 32-bit mode is the best current solution.

How to compile application to run in both 32 bit or 64 bit?
You can do it several ways...

Solution :1

You can edit your visual studio c# project file (.csproj) and put this snippet:
2.<PropertyGroup Condition=" '$(Configuration)|$(Platfor…