Posts

Showing posts from December, 2015

Add url to google

Image
For adding url click on below link Add url to google After completing this process with 2-3 days Google verify your url and based on your SEO it will ranks your site.  After applying ranking it will add your url to its database

Email sending in C#

Email sending with Attachment public static bool SendEmailMessage( string SenderEmailAddress, string SenderPassword, string SenderHostName, int SenderPort, string Subject, string Body, string emailTO, bool EnableSSL = false, string CC = "", string BCC = "", MailPriority Priority = MailPriority .Normal, string path = "") {             try             {                 System.Net.Mail.MailMessage objMail = new System.Net.Mail.MailMessage();                 //Set from address                 objMail.From = new MailAddress(SenderEmailAddress);                  // Set to addr...

Export GridView to CSV/Excel in C#

Step 1 : Bind GridView             //This allows you to bind all data of GridView into ExcelSheet             GridView1.AllowPaging = false;             GridView1.DataSource = //List Object or DataTable             GridView1.DataBind();   Step 2 : Export GridView To Excel              HttpContext .Current.Response.ClearContent();             HttpContext .Current.Response.AddHeader("content-disposition", "attachment; filename="                           + fileName + ".xls");   // fileNmae = Name of file             ...

Create DataTable from List in C#

T is type of Class which you want convert i.e. T = Class Name  public static DataTable ConvertToDataTable<T> (List <T> data)  {             //Create property description collection object of you table type object             PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(T));             DataTable table = new DataTable();            //Bind object field as header row of DataTable             foreach (PropertyDescriptor prop in properties)             {                 table.Columns.Add(prop.Name, typeof(string)); ...

Image cropping in C#

public static byte [] CropImage( string Img, int Width, int Height, int X, int Y) {             try             {                 //Generate Image from specified Image file path                 //Img = file path                 System.Drawing.Image OriginalImage = System.Drawing.Image.FromFile(Img);                 //Generate Bitmap with given Width and Height                 Bitmap bmp = new Bitmap(Width, Height);                //Set Resolution of Bitmap  ...

Convert Number into text format in C#

Below function will convert inputted number into text format public static string NumberToText( int number, bool isUK) {             // return "Zero" if number is 0             if (number == 0) return "Zero";                        string and = isUK ? "and " : ""; // deals with UK or US numbering               if (number == -2147483648) return "Minus Two Billion One Hundred " + and +             "Forty Seven Million Four Hundred " + and + "Eighty Three Thousand " +             "Six Hundred " + and + "Forty Eight";             int[] num = ...

Check string is number or not in C#

Int.TryParse() method converts string into integer and if this conversion is not possible then it will return false means your inputted string is not number string number = "1234"; int a = 0; bool isNumber = int.TryParse(number, out a); if (isNumber == true) {             //string is valid number } else {            //Given string is not a number }