Wednesday, 2 October 2013
Some Important Portals & their Founders
1. #Google— Larry Page & Sergey Brin
2. #Facebook— Mark Zuckerberg
3. #Yahoo— David Filo & Jerry Yang
4. #Twitter— Jack Dorsey & Dick Costolo
5. #Internet— Tim Berners Lee
6. #Linkdin— Reid Hoffman, Allen Blue& Koonstantin Guericke
7. #Email— Shiva Ayyadurai
8. #Gtalk— Richard Wah kan
9. #Whats up— Laurel Kirtz
10. #Hotmail— Sabeer Bhatia
11. #Orkut— Buyukkokten
12. #Wikipedia— Jimmy Wales
13. #Youtube— Steve Chen, Chad Hurley & JawedKarim
14. #Rediffmail— Ajit Balakrishnan
15. #Nimbuzz— Martin Smink & Evert Jaap Lugt
16. #Myspace— Chris Dewolfe & Tom Anderson
17. #Ibibo— Ashish Kashyap
18. #OLX— Alec Oxenford & Fabrice Grinda
19. #Skype— Niklas Zennstrom,JanusFriis & Reid Hoffman
20. #Opera— Jon Stephenson von Tetzchner & Geir lvarsoy
21. #Mozilla Firefox— Dave Hyatt & Blake Ross
22. #Blogger— Evan Willams
Sunday, 18 August 2013
Free Recharge for your mobile From Amulyam
Free Recharge for your mobile From Amulyam
The Best Website to get free recharge for Free by
1.Play Game
2.Refer Friends
3.Play Quiz
4.Attent Poll
5.Rate and Earn
6.Create Contest and Earn
Enjoy !!!
Click Here to Join Now
Wednesday, 31 July 2013
Thursday, 25 July 2013
What is .htaccess?
What is .htaccess?
Using .htaccess files lets you control the behavior of your site or a specific directory on your site. For example, if you place an .htaccess file in your root directory, it will affect your entire site (www.coolexample.com). If you place it in a /content directory, it will only affect that directory (www.coolexample.com/content).
.htaccess works on our Linux servers.
Using an .htaccess file, you can:
- Customize the Error pages for your site.
- Protect your site with a password.
- Enable server-side includes.
- Deny access to your site based on IP.
- Change your default directory page (index.html).
- Redirect visitors to another page.
- Prevent directory listing.
- Add MIME types.
.htaccess files are a simple ASCII text file with the name .htaccess. It is not an extension like .html or .txt. The entire file name is .htaccess. For more information on how to set up .htaccess files, visit Apache's Website
Monday, 22 July 2013
Import Excel or CSV File To MySql Using Query
Import Excel or CSV File To MySql Using Query
load data local infile 'path\file.csv' into table Table_Name fields terminated by ',' enclosed by '"' lines terminated by '\n';
load data local infile 'path\file.csv' into table Table_Name fields terminated by ',' enclosed by '"' lines terminated by '\n';
Saturday, 6 July 2013
Access Specifiers In .Net
Access Specifiers In .Net
Public --
As name specifies, it can be accessed from anywhere.If a member of
class is defined as public then it can be accessed anywhere.
Private -- Accessible inside the class only through member functions.
Protected -- protected variables can be used with in the class as well as the classes that inherits this class
Friend/Internal --
Friend and Internal mean the same. Friend is used in VB.Net.Internal is
used in C#. Internal can be accessed by all classes with in an assembly
but not from outside the assembly.
Protected Internal -- Visible inside the assembly through objects and in derived classes outside the assembly through member functions.
Object Oriented Programming Concepts (OOPS) in C#.net
1. Object - Instance of Class
2. Class - Blue print of Object
3. Encapsulation - Protecting our Data
4. Polymorphism - Different behaviors at different instances
5. Abstraction - Hiding our irrelevant Data
6. Inheritence - One property of object is acquiring to another property of object
2. Class - Blue print of Object
3. Encapsulation - Protecting our Data
4. Polymorphism - Different behaviors at different instances
5. Abstraction - Hiding our irrelevant Data
6. Inheritence - One property of object is acquiring to another property of object
Monday, 1 July 2013
Create a Excel file and Add Data Into it Using Asp .Net Using C#
Response.Clear();
Response.Buffer =
true
;
Response.ContentType =
"application/vnd.ms-excel"
;
Response.AddHeader(
"Content-Disposition"
,
"attachment;filename=registrationData.xls"
);
this
.EnableViewState =
false
;
using
( StringWriter sw =
new
StringWriter() )
using
( HtmlTextWriter htw =
new
HtmlTextWriter( sw ) )
{
// Create a table to contain the grid
Table table =
new
Table();
// Gridline to box the cells
table.GridLines = System.Web.UI.WebControls.GridLines.Both;
List columns =
new
List() {
"Sent"
,
"Sent Date"
,
"User Name"
,
"Last Name"
,
"First Name"
,
"Work Phone"
,
"Work Email"
,
"Number of Tickets"
,
"Street Address 1"
,
"Street Address 2"
,
"City"
,
"State"
,
"Zip Code"
};
TableRow tRow =
new
TableRow();
string
value;
foreach
(
string
name
in
columns )
tRow.Cells.Add(
new
TableCell() { Text = name } );
table.Rows.Add( tRow );
// BackColor = System.Drawing.Color.Blue
foreach
( var usr
in
UserData )
{
tRow =
new
TableRow();
value = ( usr.ticketsSent ==
null
) ?
"N"
: usr.ticketsSent.Value.ToString();
tRow.Cells.Add(
new
TableCell() { Text = value } );
value = ( usr.ticketsSentDate ==
null
) ?
string
.Empty : usr.ticketsSentDate.Value.ToShortDateString();
tRow.Cells.Add(
new
TableCell() { Text = value } );
tRow.Cells.Add(
new
TableCell() { Text = usr.userName } );
tRow.Cells.Add(
new
TableCell() { Text = usr.lastName } );
tRow.Cells.Add(
new
TableCell() { Text = usr.firstName } );
tRow.Cells.Add(
new
TableCell() { Text = usr.workNumber } );
tRow.Cells.Add(
new
TableCell() { Text = usr.workEmail } );
tRow.Cells.Add(
new
TableCell() { Text = usr.ticketsRequested.Value.ToString() } );
tRow.Cells.Add(
new
TableCell() { Text = usr.address1 } );
tRow.Cells.Add(
new
TableCell() { Text = usr.address2 } );
tRow.Cells.Add(
new
TableCell() { Text = usr.city } );
tRow.Cells.Add(
new
TableCell() { Text = usr.state } );
tRow.Cells.Add(
new
TableCell() { Text = usr.zipCode } );
table.Rows.Add( tRow );
}
// Htmlwriter into the table
table.RenderControl( htw );
// Htmlwriter into the response
HttpContext.Current.Response.Write( sw.ToString() );
HttpContext.Current.Response.End();
}
Thursday, 27 June 2013
Learn How to Write Regular Expression In .Net using C#
Learn How to Write Regular Expression In .Net using C#
So, what’s the agenda?
Regex has been the most popular and easiest way of writing validations. The only big problem with regex has been the cryptic syntax. Developers who are working on projects with complicated validation always refer some kind of cheat sheet to remember the syntaxes and commands.In this article we will try to understand what regex is and how to remember those cryptic syntaxes easily.
You can watch my .NET interview questions and answers videos on various sections like WCF, SilverLight, LINQ, WPF, Design patterns, Entity framework etc.
Just in case if you are new comer, what is regex?
Regex or regular expression helps us describe complex patterns in texts. Once you have described these patterns you can use them to do searching, replacing, extracting and modifying text data.Below is a simple sample of regex. The first step is to import the namespace for regular expressions.
using System.Text.RegularExpressions;
The next thing is to create the regex object with the pattern. The
below pattern specifies to search for alphabets between a-z with 10
length.Regex obj = new Regex(“[a-z]{10}”);Finally search the pattern over the data to see if there are matches. In case the pattern is matching the ‘IsMatch’ will return true.
MessageBox.Show(obj.IsMatch(“shivkoirala”).ToString());
3 important regex commands
The best way to remember regex syntax is by remembering three things Bracket, caret and Dollars.B | There are 3 types of brackets used in regular expression Square brackets “[“and Curly “{“ brackets. Square brackets specify the character which needs to be matched while curly brackets specify how many characters. “(“ for grouping. We will understand the same as we move ahead in this article. |
C | caret “^” the start of a regular expression. |
D | Dollar “$” specifies the end of a regular expression. |
- The above regex pattern will only take characters which lies between ‘a’ to ‘z’. The same is marked with square bracket to define the range.
- The round bracket indicates the minimum and maximum length.
- Finally caret sign at the start of regex pattern and dollar at the end of regex pattern specifies the start and end of the pattern to make the validation more rigid.
Check if the user has entered shivkoirala?
shivkoirala
Let’s start with the first validation, enter character which exists between a-g?
[a-g]
Enter characters between [a-g] with length of 3?
[a-g]{3}
Enter characters between [a-g] with maximum 3 characters and minimum 1 character?
[a-g]{1,3}
How can I validate data with 8 digit fix numeric format like 91230456, 01237648 etc?
^[0-9]{8}$
How to validate numeric data with minimum length of 3 and maximum of 7, ex -123, 1274667, 87654?
We need to just tweak the first validation with adding a comma and defining the minimum and maximum length inside curly brackets.^[0-9]{3,7}$
Validate invoice numbers which have formats like LJI1020, the first 3 characters are alphabets and remaining is 8 length number?
First 3 character validation | ^[a-z]{3}
|
8 length number validation | [0-9]{8} |
Now butting the whole thing together.
^[a-z]{3}[0-9]{7}$
Check for format INV190203 or inv820830, with first 3 characters alphabets case insensitive and remaining 8 length numeric?
In the previous question the regex validator will only validate first
3 characters of the invoice number if it is in small letters. If you
put capital letters it will show as invalid. To ensure that the first 3
letters are case insensitive we need to use ^[a-zA-Z]{3} for character
validation.Below is how the complete regex validation looks like.
^[a-zA-Z]{3}[0-9]{7}$
Can we see a simple validation for website URL’s?
Steps | Regex |
Step 1 :- Check is www exist | ^www. |
Step 2 :-The domain name should be atleast 1 character and maximum character will be 15. | . [a-z]{1,15} |
Step 3 :-Finally should end with .com or .org | . (com|org)$ |
^www[.][a-z]{1,15}[.](com|org)$
Let’s see if your BCD works for email validation?
Steps | Regex |
Step 1 :- Email can start with alphanumeric with minimum 1 character and maximum 10 character. , followed by at the rate (@) | ^[a-zA-Z0-9]{1,10}@ |
Step 2 :-The domain name after the @ can be alphanumeric with minimum 1 character and maximum 10 character , followed by a “.” | [a-zA-Z]{1,10}. |
Step 3 :-Finally should end with .com or .org | .(com|org)$ |
^[a-zA-Z0-9]{1,10}@[a-zA-Z]{1,10}.(com|org)$
Validate numbers are between 0 to 25
^(([0-9])|([0-1][0-9])|([0-2][0-5]))$
Validate a date with MM/DD/YYYY, YYYY/MM/DD and DD/MM/YYYY
Steps | Regex | Description |
Let check for DD. First DD has a range of 1-29 ( feb) , 1-30 (small months) , 1-31 (long month) . So for DD 1-9 or 01-09 |
[1-9]|0[1-9] | This allow user to enter value between 1 to 9 or 01 to 09. |
Now also adding DD check of 10 to 19 | [1-9]|1[0-9] | This allows user to enter the value between 01 to 19. |
Now adding to above DD check of 20 to 29 | [1-9]|1[0-9]|2[0-9] | This allows user to enter the value between 01 to 29. |
Now adding to above DD check of 30 to 31 | [1-9]|1[0-9]|2[0-9]|3[0-1] | Finally user can enter value between 01 to 31. |
Now for seperator it can be a / , - | [/ . -] | This allows user to seperate date by defining seperator. |
Now same applying for MM | [1-9]|0[1-9]|1[0-2] | This allow user to enter month value between 01 to 12. |
Then for a YY | 1[9][0-9][0-9]|2[0][0-9][0-9] | allow user enter the year value between 1900 to 2099. |
^([1-9]|0[1-9]|1[0-9]|2[0-9]|3[0-1])[- / .]([1-9]|0[1-9]|1[0-2])[- / .](1[9][0-9][0-9]|2[0][0-9][0-9])$ for "DD/MM/YYYY"To get MM/DD/YYYY use the following regex pattern.
^([1-9]|0[1-9]|1[0-2])[- / .]([1-9]|0[1-9]|1[0-9]|2[0-9]|3[0-1])[- / .](1[9][0-9][0-9]|2[0][0-9][0-9])$And finally to get YYYY/MM/DD use the following regex pattern.
^(1[9][0-9][0-9]|2[0][0-9][0-9])[- / .]([1-9]|0[1-9]|1[0-2])[- / .]([1-9]|0[1-9]|1[0-9]|2[0-9]|3[0-1])$
Short cuts
You can also use the below common shortcut commands to shorten your regex validation.Actual commands | Shortcuts |
[0-9] | \d |
[a-z][0-9][_] | \w |
O or more occurrences | * |
1 or more occurrences | + |
0 or 1 occurrence | ? |
Wednesday, 26 June 2013
SQL Injection In PHP
SQL Injection
Use Case#1: SQL Injection.
SQL injection is common problem and most of the hackers are used this technique to hack the site’s information and also most importantly they can destroyed your site completely. Here I want to share some common phenomena about SQL injection
Let, you have one login form where your user can access some resource from your site after successfully login. You have two input fields for user name and password.
After SQL injection
– used for SQL comments.
Strangely, hacker can access someone’s information
Use Case#2: SQL Injection.
Someone can drop your kwon tables and very strangely your whole database. Like you have one select sql command for searching a product.
after SQL injection,
Protection:
it returns
1234\’ or 1; and the SQL command becomes
**userPass has no ending single quotation tag. So it generates SQL error but prevents from hacking.
SQL injection is common problem and most of the hackers are used this technique to hack the site’s information and also most importantly they can destroyed your site completely. Here I want to share some common phenomena about SQL injection
Let, you have one login form where your user can access some resource from your site after successfully login. You have two input fields for user name and password.
User Name | admin |
Password | admin |
select userID from userTable where userName=’admin’ and userPass=’admin’;
After SQL injection
User Name | admin |
Password | 1234’ or 1; – |
select userID from userTable where userName=’admin’ and userPass=’1234’ or 1; --‘;
Strangely, hacker can access someone’s information
Use Case#2: SQL Injection.
Someone can drop your kwon tables and very strangely your whole database. Like you have one select sql command for searching a product.
Search: | food |
select productName, productPrice from productTables where productName like ‘%food%’;
after SQL injection,
Search: | food’; drop table user; – |
select productName, productPrice from productTables where productName like ‘%food’; drop table user; --%’;
Protection:
- For password issue, we need to use md5 hash format to store user password at database. And also we need to convert user inputted password for matching with database. So, for Use Case #1, the sql injected code is also converted at md5 hash format before matching with database.
md5(1234’ or 1; --) ;
- php has one function named ‘mysql_real_escape_string()’ to prevent hacking. It placed backslash if it found any special character. Like
mysql_real_escape_string(1234’ or 1;);
it returns
1234\’ or 1; and the SQL command becomes
select userID from userTable where userName=’admin’ and userPass=’1234\’ or 1; --‘;
**userPass has no ending single quotation tag. So it generates SQL error but prevents from hacking.
Friday, 21 June 2013
Generate Unique ID in Asp .Net using C#
Generate Unique ID in Asp .Net using C#
string id = Convert.ToString(Guid.NewGuid());
string id = Convert.ToString(Guid.NewGuid());
Wednesday, 8 May 2013
Validate Extension Of Selected File In File Uploader Before Uploading in Asp .Net C#
Validate Extension Of Selected File In File Uploader Before Uploading in Asp .Net C#Using RegularExpressionValidator ..
<asp:FileUpload ID="fuParon" runat="server" />
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server"
ErrorMessage="Only Excel file is allowed!"
ValidationExpression ="^.+(.xls|.xlsx)$" ControlToValidate="fuParon"
style="color: #FF5050" ValidationGroup="upload" ></asp:RegularExpressionValidator>
<asp:ImageButton ID="BtnUpload" runat="server" ImageUrl="uploadimage.png" Width=30px Height=30px ValidationGroup="upload" />
<asp:FileUpload ID="fuParon" runat="server" />
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server"
ErrorMessage="Only Excel file is allowed!"
ValidationExpression ="^.+(.xls|.xlsx)$" ControlToValidate="fuParon"
style="color: #FF5050" ValidationGroup="upload" ></asp:RegularExpressionValidator>
<asp:ImageButton ID="BtnUpload" runat="server" ImageUrl="uploadimage.png" Width=30px Height=30px ValidationGroup="upload" />
Sunday, 5 May 2013
Get Next Auto Increment Value of a Table in MySql
SELECT AUTO_INCREMENT FROM information_schema.`tables` WHERE TABLE_SCHEMA ='DatabaseName' AND TABLE_NAME = 'TableName'
Friday, 12 April 2013
Show Message Box In ASP .Net with C# From Server Side
ClientScript.RegisterStartupScript(Page.GetType(), "alert", "<script language='javascript'>alert('HAI MUKESH')</script>");
Friday, 5 April 2013
Generate Barcode in C# ASP.Net
How to Generate Barcode , Save It Into a folder and Display Generated Barcode
1. Initially You have to download the open source DLL iTextSharp(For Create Pdf)
2. Add the iTextSharp DLL To the project.
3. Create a folder with name barcodes to store barcode inside the pdf.
4. Add iTextSharp namespace to the Project.
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
5. Store the value you want to Generate Barcode in to the Variable Code
6. Then you can generate barcodes.
7.Go and see the barcodes Folder In the Project to see the generated Barcode inside Pdf
Name Spaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Imaging;
using System.IO;
using System.Data;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using System.Text;
using System.IO.Ports;
using System.Net;
Barcode Generating Code
string id = Guid.NewGuid().ToString();
MemoryStream MS = new MemoryStream();
Document pdfDoc = new Document(PageSize.A4, 10, 10, 10, 10);
PdfWriter.GetInstance(pdfDoc, MS);
pdfDoc.Open();
// string code = dtExcelData.Rows[j].ItemArray[0].ToString();
string sWorkPath = "";
sWorkPath = this.Context.Server.MapPath("");
// string Code = code;
string Code ="12345";
// Multiply the lenght of the code by 40 (just to have enough width)
int w = Code.Length * 40;
// int w = Code.Length * 25;
// Create a bitmap object of the width that we calculated and height of 100
Bitmap oBitmap = new Bitmap(w, 100);
// then create a Graphic object for the bitmap we just created.
Graphics oGraphics = Graphics.FromImage(oBitmap);
PrivateFontCollection fnts = new PrivateFontCollection();
fnts.AddFontFile(sWorkPath + @"\IDAutomationHC39M.ttf");
FontFamily fntfam = new FontFamily("IDAutomationHC39M", fnts);
System.Drawing.Font oFont = new System.Drawing.Font(fntfam, 18);
PointF oPoint = new PointF(2f, 2f);
SolidBrush oBrushWrite = new SolidBrush(Color.Black);
SolidBrush oBrush = new SolidBrush(Color.White);
oGraphics.FillRectangle(oBrush, 0, 0, w, 100);
oGraphics.DrawString("*" + Code + "*", oFont, oBrushWrite, oPoint);
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
using (MemoryStream ms = new MemoryStream())
{
oBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
Convert.ToBase64String(byteImage);
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
iTextSharp.text.Image i = iTextSharp.text.Image.GetInstance(oBitmap, System.Drawing.Imaging.ImageFormat.Bmp);
pdfDoc.Add(i);
pdfDoc.Close();
Response.Buffer = true;
byte[] content = MS.ToArray();
using (FileStream fs = File.Create(Server.MapPath("~/barcodes/" + id + ".pdf")))
{
fs.Write(content, 0, (int)content.Length);
}
System.Diagnostics.Process.Start(Server.MapPath("~/barcodes/" + id + ".pdf"));
Output
1. Initially You have to download the open source DLL iTextSharp(For Create Pdf)
2. Add the iTextSharp DLL To the project.
3. Create a folder with name barcodes to store barcode inside the pdf.
4. Add iTextSharp namespace to the Project.
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
5. Store the value you want to Generate Barcode in to the Variable Code
6. Then you can generate barcodes.
7.Go and see the barcodes Folder In the Project to see the generated Barcode inside Pdf
Name Spaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Imaging;
using System.IO;
using System.Data;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using System.Text;
using System.IO.Ports;
using System.Net;
Barcode Generating Code
string id = Guid.NewGuid().ToString();
MemoryStream MS = new MemoryStream();
Document pdfDoc = new Document(PageSize.A4, 10, 10, 10, 10);
PdfWriter.GetInstance(pdfDoc, MS);
pdfDoc.Open();
// string code = dtExcelData.Rows[j].ItemArray[0].ToString();
string sWorkPath = "";
sWorkPath = this.Context.Server.MapPath("");
// string Code = code;
string Code ="12345";
// Multiply the lenght of the code by 40 (just to have enough width)
int w = Code.Length * 40;
// int w = Code.Length * 25;
// Create a bitmap object of the width that we calculated and height of 100
Bitmap oBitmap = new Bitmap(w, 100);
// then create a Graphic object for the bitmap we just created.
Graphics oGraphics = Graphics.FromImage(oBitmap);
PrivateFontCollection fnts = new PrivateFontCollection();
fnts.AddFontFile(sWorkPath + @"\IDAutomationHC39M.ttf");
FontFamily fntfam = new FontFamily("IDAutomationHC39M", fnts);
System.Drawing.Font oFont = new System.Drawing.Font(fntfam, 18);
PointF oPoint = new PointF(2f, 2f);
SolidBrush oBrushWrite = new SolidBrush(Color.Black);
SolidBrush oBrush = new SolidBrush(Color.White);
oGraphics.FillRectangle(oBrush, 0, 0, w, 100);
oGraphics.DrawString("*" + Code + "*", oFont, oBrushWrite, oPoint);
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
using (MemoryStream ms = new MemoryStream())
{
oBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
Convert.ToBase64String(byteImage);
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
iTextSharp.text.Image i = iTextSharp.text.Image.GetInstance(oBitmap, System.Drawing.Imaging.ImageFormat.Bmp);
pdfDoc.Add(i);
pdfDoc.Close();
Response.Buffer = true;
byte[] content = MS.ToArray();
using (FileStream fs = File.Create(Server.MapPath("~/barcodes/" + id + ".pdf")))
{
fs.Write(content, 0, (int)content.Length);
}
System.Diagnostics.Process.Start(Server.MapPath("~/barcodes/" + id + ".pdf"));
Output
Thursday, 28 March 2013
Send Email with attachment In Asp .Net with c#
Send Email with attachment In Asp .Net with c#
string filePath ="C:\\abc.doc";
string senderEmailid="senderemailid@gmail.com";
string senderPassword="password";
string recieverEmailid="recievermailid@gmail.com";
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential(senderEmailid, senderPassword),
EnableSsl = true
};
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(senderEmailid, recieverEmailid);
mail.Attachments.Add(new Attachment(Server.MapPath(filePath)));
mail.Subject ="Subject of Mail"
mail.Body ="<b>Hai</b>";
mail.IsBodyHtml = true; // To make html
client.Send(mail);
string filePath ="C:\\abc.doc";
string senderEmailid="senderemailid@gmail.com";
string senderPassword="password";
string recieverEmailid="recievermailid@gmail.com";
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential(senderEmailid, senderPassword),
EnableSsl = true
};
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(senderEmailid, recieverEmailid);
mail.Attachments.Add(new Attachment(Server.MapPath(filePath)));
mail.Subject ="Subject of Mail"
mail.Body ="<b>Hai</b>";
mail.IsBodyHtml = true; // To make html
client.Send(mail);
Sunday, 24 March 2013
Method to Convert Number to Words Asp .Net C#
Method to Convert Number to Words Asp .Net C#
private string NumberToWords(int number)
{
if (number == 0)
return "zero";
if (number < 0)
return "minus " + NumberToWords(Math.Abs(number));
string words = "";
if ((number / 1000000000) > 0)
{
words += NumberToWords(number / 1000000000) + " Billion ";
number %= 1000000000;
}
if ((number / 10000000) > 0)
{
words += NumberToWords(number / 10000000) + " Crore ";
number %= 10000000;
}
if ((number / 1000000) > 0)
{
words += NumberToWords(number / 1000000) + " million ";
number %= 1000000;
}
if ((number / 100000) > 0)
{
words += NumberToWords(number / 100000) + " lakh ";
number %= 100000;
}
if ((number / 1000) > 0)
{
words += NumberToWords(number / 1000) + " thousand ";
number %= 1000;
}
if ((number / 100) > 0)
{
words += NumberToWords(number / 100) + " hundred ";
number %= 100;
}
if (number > 0)
{
if (words != "")
words += "and ";
var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };
if (number < 20)
words += unitsMap[number];
else
{
words += tensMap[number / 10];
if ((number % 10) > 0)
words += "-" + unitsMap[number % 10];
}
}
return words;
}
Example :
NumberToWords(33333); //Calling Method
Output
thirty-three thousand three hundred and thirty-three
private string NumberToWords(int number)
{
if (number == 0)
return "zero";
if (number < 0)
return "minus " + NumberToWords(Math.Abs(number));
string words = "";
if ((number / 1000000000) > 0)
{
words += NumberToWords(number / 1000000000) + " Billion ";
number %= 1000000000;
}
if ((number / 10000000) > 0)
{
words += NumberToWords(number / 10000000) + " Crore ";
number %= 10000000;
}
if ((number / 1000000) > 0)
{
words += NumberToWords(number / 1000000) + " million ";
number %= 1000000;
}
if ((number / 100000) > 0)
{
words += NumberToWords(number / 100000) + " lakh ";
number %= 100000;
}
if ((number / 1000) > 0)
{
words += NumberToWords(number / 1000) + " thousand ";
number %= 1000;
}
if ((number / 100) > 0)
{
words += NumberToWords(number / 100) + " hundred ";
number %= 100;
}
if (number > 0)
{
if (words != "")
words += "and ";
var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };
if (number < 20)
words += unitsMap[number];
else
{
words += tensMap[number / 10];
if ((number % 10) > 0)
words += "-" + unitsMap[number % 10];
}
}
return words;
}
Example :
NumberToWords(33333); //Calling Method
Output
thirty-three thousand three hundred and thirty-three
Friday, 15 March 2013
Find the full details of a IP by API
Through this api you can get all the details of the ip including location,region,state,Country...etc
http://api.easyjquery.com/ips/?full=true&ip=VISITOR_IP_HERE
It is a free api from http://www.easyjquery.com/2012/11/geo-api-detect-clients-ip-country-city-with-javascript-php/
http://api.easyjquery.com/ips/?full=true&ip=VISITOR_IP_HERE
It is a free api from http://www.easyjquery.com/2012/11/geo-api-detect-clients-ip-country-city-with-javascript-php/
Thursday, 7 February 2013
Display Calendar on Continous Pressing of key C , Jquery UI
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Press C continously</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<script>
var ss=0;
$(document).keypress("c",function(e) {
if(ss==3)
{
$( ".showcalender" ).datepicker();
ss=0;
}
else
{
ss++;
}
});
$(document).keyup("c",function(e) {
ss=0;
});
</script>
</head>
<body>
<div class='showcalender' style='left:30%;top:20%;position:fixed'></div>
</body>
</html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Press C continously</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<script>
var ss=0;
$(document).keypress("c",function(e) {
if(ss==3)
{
$( ".showcalender" ).datepicker();
ss=0;
}
else
{
ss++;
}
});
$(document).keyup("c",function(e) {
ss=0;
});
</script>
</head>
<body>
<div class='showcalender' style='left:30%;top:20%;position:fixed'></div>
</body>
</html>
Monday, 21 January 2013
PHP Password Encryption And Decription
<?php
//Key
$key = 'secretkey';
//To Encrypt:
$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, 'mukesh', MCRYPT_MODE_ECB);
echo $encrypted;
echo "<br>";
//To Decrypt:
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB);
echo $decrypted;
?>
Country Name and codes in Select Box
<select
class="PhoneCountryCode">
<option value="Afghanistan (+93)">Afghanistan (+93)</option>
<option value="Albania (+355)">Albania (+355)</option>
<option value="Algeria (+213)">Algeria (+213)</option>
<option value="American Samoa (+1)">American Samoa (+1)</option>
<option value="Andorra (+376)">Andorra (+376)</option>
<option value="Angola (+244)">Angola (+244)</option>
<option value="Anguilla (+1)">Anguilla (+1)</option>
<option value="Antigua (+1)">Antigua (+1)</option>
<option value="Argentina (+54)">Argentina (+54)</option>
<option value="Armenia (+374)">Armenia (+374)</option>
<option value="Aruba (+297)">Aruba (+297)</option>
<option value="Australia (+61)">Australia (+61)</option>
<option value="Austria (+43)">Austria (+43)</option>
<option value="Azerbaijan (+994)">Azerbaijan (+994)</option>
<option value="Bahrain (+973)">Bahrain (+973)</option>
<option value="Bangladesh (+880)">Bangladesh (+880)</option>
<option value="Barbados (+1)">Barbados (+1)</option>
<option value="Belarus (+375)">Belarus (+375)</option>
<option value="Belgium (+32)">Belgium (+32)</option>
<option value="Belize (+501)">Belize (+501)</option>
<option value="Benin (+229)">Benin (+229)</option>
<option value="Bermuda (+1)">Bermuda (+1)</option>
<option value="Bhutan (+975)">Bhutan (+975)</option>
<option value="Bolivia (+591)">Bolivia (+591)</option>
<option value="Bonaire, Sint Eustatius and Saba (+599)">Bonaire, Sint Eustatius and Saba (+599)</option>
<option value="Bosnia and Herzegovina (+387)">Bosnia and Herzegovina (+387)</option>
<option value="Botswana (+267)">Botswana (+267)</option>
<option value="Brazil (+55)">Brazil (+55)</option>
<option value="British Indian Ocean Territory (+246)">British Indian Ocean Territory (+246)</option>
<option value="British Virgin Islands (+1)">British Virgin Islands (+1)</option>
<option value="Brunei (+673)">Brunei (+673)</option>
<option value="Bulgaria (+359)">Bulgaria (+359)</option>
<option value="Burkina Faso (+226)">Burkina Faso (+226)</option>
<option value="Burundi (+257)">Burundi (+257)</option>
<option value="Cambodia (+855)">Cambodia (+855)</option>
<option value="Cameroon (+237)">Cameroon (+237)</option>
<option value="Canada (+1)">Canada (+1)</option>
<option value="Cape Verde (+238)">Cape Verde (+238)</option>
<option value="Cayman Islands (+1)">Cayman Islands (+1)</option>
<option value="Central African Republic (+236)">Central African Republic (+236)</option>
<option value="Chad (+235)">Chad (+235)</option>
<option value="Chile (+56)">Chile (+56)</option>
<option value="China (+86)">China (+86)</option>
<option value="Colombia (+57)">Colombia (+57)</option>
<option value="Comoros (+269)">Comoros (+269)</option>
<option value="Cook Islands (+682)">Cook Islands (+682)</option>
<option value="Costa Rica (+506)">Costa Rica (+506)</option>
<option value="Côte d'Ivoire (+225)">Côte d'Ivoire (+225)</option>
<option value="Croatia (+385)">Croatia (+385)</option>
<option value="Cuba (+53)">Cuba (+53)</option>
<option value="Curaçao (+599)">Curaçao (+599)</option>
<option value="Cyprus (+357)">Cyprus (+357)</option>
<option value="Czech Republic (+420)">Czech Republic (+420)</option>
<option value="Democratic Republic of the Congo (+243)">Democratic Republic of the Congo (+243)</option>
<option value="Denmark (+45)">Denmark (+45)</option>
<option value="Djibouti (+253)">Djibouti (+253)</option>
<option value="Dominica (+1)">Dominica (+1)</option>
<option value="Dominican Republic (+1)">Dominican Republic (+1)</option>
<option value="Ecuador (+593)">Ecuador (+593)</option>
<option value="Egypt (+20)">Egypt (+20)</option>
<option value="El Salvador (+503)">El Salvador (+503)</option>
<option value="Equatorial Guinea (+240)">Equatorial Guinea (+240)</option>
<option value="Eritrea (+291)">Eritrea (+291)</option>
<option value="Estonia (+372)">Estonia (+372)</option>
<option value="Ethiopia (+251)">Ethiopia (+251)</option>
<option value="Falkland Islands (+500)">Falkland Islands (+500)</option>
<option value="Faroe Islands (+298)">Faroe Islands (+298)</option>
<option value="Federated States of Micronesia (+691)">Federated States of Micronesia (+691)</option>
<option value="Fiji (+679)">Fiji (+679)</option>
<option value="Finland (+358)">Finland (+358)</option>
<option value="France (+33)">France (+33)</option>
<option value="French Guiana (+594)">French Guiana (+594)</option>
<option value="French Polynesia (+689)">French Polynesia (+689)</option>
<option value="Gabon (+241)">Gabon (+241)</option>
<option value="Georgia (+995)">Georgia (+995)</option>
<option value="Germany (+49)">Germany (+49)</option>
<option value="Ghana (+233)">Ghana (+233)</option>
<option value="Gibraltar (+350)">Gibraltar (+350)</option>
<option value="Greece (+30)">Greece (+30)</option>
<option value="Greenland (+299)">Greenland (+299)</option>
<option value="Grenada (+1)">Grenada (+1)</option>
<option value="Guadeloupe (+590)">Guadeloupe (+590)</option>
<option value="Guam (+1)">Guam (+1)</option>
<option value="Guatemala (+502)">Guatemala (+502)</option>
<option value="Guinea (+224)">Guinea (+224)</option>
<option value="Guinea-Bissau (+245)">Guinea-Bissau (+245)</option>
<option value="Guyana (+592)">Guyana (+592)</option>
<option value="Haiti (+509)">Haiti (+509)</option>
<option value="Honduras (+504)">Honduras (+504)</option>
<option value="Hong Kong (+852)">Hong Kong (+852)</option>
<option value="Hungary (+36)">Hungary (+36)</option>
<option value="Iceland (+354)">Iceland (+354)</option>
<option value="India (+91)">India (+91)</option>
<option value="Indonesia (+62)">Indonesia (+62)</option>
<option value="Iran (+98)">Iran (+98)</option>
<option value="Iraq (+964)">Iraq (+964)</option>
<option value="Ireland (+353)">Ireland (+353)</option>
<option value="Israel (+972)">Israel (+972)</option>
<option value="Italy (+39)">Italy (+39)</option>
<option value="Jamaica (+1)">Jamaica (+1)</option>
<option value="Japan (+81)">Japan (+81)</option>
<option value="Jordan (+962)">Jordan (+962)</option>
<option value="Kazakhstan (+7)">Kazakhstan (+7)</option>
<option value="Kenya (+254)">Kenya (+254)</option>
<option value="Kiribati (+686)">Kiribati (+686)</option>
<option value="Kosovo (+381)">Kosovo (+381)</option>
<option value="Kuwait (+965)">Kuwait (+965)</option>
<option value="Kyrgyzstan (+996)">Kyrgyzstan (+996)</option>
<option value="Laos (+856)">Laos (+856)</option>
<option value="Latvia (+371)">Latvia (+371)</option>
<option value="Lebanon (+961)">Lebanon (+961)</option>
<option value="Lesotho (+266)">Lesotho (+266)</option>
<option value="Liberia (+231)">Liberia (+231)</option>
<option value="Libya (+218)">Libya (+218)</option>
<option value="Liechtenstein (+423)">Liechtenstein (+423)</option>
<option value="Lithuania (+370)">Lithuania (+370)</option>
<option value="Luxembourg (+352)">Luxembourg (+352)</option>
<option value="Macau (+853)">Macau (+853)</option>
<option value="Macedonia (+389)">Macedonia (+389)</option>
<option value="Madagascar (+261)">Madagascar (+261)</option>
<option value="Malawi (+265)">Malawi (+265)</option>
<option value="Malaysia (+60)">Malaysia (+60)</option>
<option value="Maldives (+960)">Maldives (+960)</option>
<option value="Mali (+223)">Mali (+223)</option>
<option value="Malta (+356)">Malta (+356)</option>
<option value="Marshall Islands (+692)">Marshall Islands (+692)</option>
<option value="Martinique (+596)">Martinique (+596)</option>
<option value="Mauritania (+222)">Mauritania (+222)</option>
<option value="Mauritius (+230)">Mauritius (+230)</option>
<option value="Mayotte (+262)">Mayotte (+262)</option>
<option value="Mexico (+52)">Mexico (+52)</option>
<option value="Moldova (+373)">Moldova (+373)</option>
<option value="Monaco (+377)">Monaco (+377)</option>
<option value="Mongolia (+976)">Mongolia (+976)</option>
<option value="Montenegro (+382)">Montenegro (+382)</option>
<option value="Montserrat (+1)">Montserrat (+1)</option>
<option value="Morocco (+212)">Morocco (+212)</option>
<option value="Mozambique (+258)">Mozambique (+258)</option>
<option value="Myanmar (+95)">Myanmar (+95)</option>
<option value="Namibia (+264)">Namibia (+264)</option>
<option value="Nauru (+674)">Nauru (+674)</option>
<option value="Nepal (+977)">Nepal (+977)</option>
<option value="Netherlands (+31)">Netherlands (+31)</option>
<option value="New Caledonia (+687)">New Caledonia (+687)</option>
<option value="New Zealand (+64)">New Zealand (+64)</option>
<option value="Nicaragua (+505)">Nicaragua (+505)</option>
<option value="Niger (+227)">Niger (+227)</option>
<option value="Nigeria (+234)">Nigeria (+234)</option>
<option value="Niue (+683)">Niue (+683)</option>
<option value="Norfolk Island (+672)">Norfolk Island (+672)</option>
<option value="North Korea (+850)">North Korea (+850)</option>
<option value="Northern Mariana Islands (+1)">Northern Mariana Islands (+1)</option>
<option value="Norway (+47)">Norway (+47)</option>
<option value="Oman (+968)">Oman (+968)</option>
<option value="Pakistan (+92)">Pakistan (+92)</option>
<option value="Palau (+680)">Palau (+680)</option>
<option value="Palestine (+970)">Palestine (+970)</option>
<option value="Panama (+507)">Panama (+507)</option>
<option value="Papua New Guinea (+675)">Papua New Guinea (+675)</option>
<option value="Paraguay (+595)">Paraguay (+595)</option>
<option value="Peru (+51)">Peru (+51)</option>
<option value="Philippines (+63)">Philippines (+63)</option>
<option value="Poland (+48)">Poland (+48)</option>
<option value="Portugal (+351)">Portugal (+351)</option>
<option value="Puerto Rico (+1)">Puerto Rico (+1)</option>
<option value="Qatar (+974)">Qatar (+974)</option>
<option value="Republic of the Congo (+242)">Republic of the Congo (+242)</option>
<option value="Réunion (+262)">Réunion (+262)</option>
<option value="Romania (+40)">Romania (+40)</option>
<option value="Russia (+7)">Russia (+7)</option>
<option value="Rwanda (+250)">Rwanda (+250)</option>
<option value="Saint Barthélemy (+590)">Saint Barthélemy (+590)</option>
<option value="Saint Helena (+290)">Saint Helena (+290)</option>
<option value="Saint Kitts and Nevis (+1)">Saint Kitts and Nevis (+1)</option>
<option value="Saint Martin (+590)">Saint Martin (+590)</option>
<option value="Saint Pierre and Miquelon (+508)">Saint Pierre and Miquelon (+508)</option>
<option value="Saint Vincent and the Grenadines (+1)">Saint Vincent and the Grenadines (+1)</option>
<option value="Samoa (+685)">Samoa (+685)</option>
<option value="San Marino (+378)">San Marino (+378)</option>
<option value="Sao Tome and Principe (+239)">Sao Tome and Principe (+239)</option>
<option value="Saudi Arabia (+966)">Saudi Arabia (+966)</option>
<option value="Senegal (+221)">Senegal (+221)</option>
<option value="Serbia (+381)">Serbia (+381)</option>
<option value="Seychelles (+248)">Seychelles (+248)</option>
<option value="Sierra Leone (+232)">Sierra Leone (+232)</option>
<option value="Singapore (+65)">Singapore (+65)</option>
<option value="Sint Maarten (+599)">Sint Maarten (+599)</option>
<option value="Slovakia (+421)">Slovakia (+421)</option>
<option value="Slovenia (+386)">Slovenia (+386)</option>
<option value="Solomon Islands (+677)">Solomon Islands (+677)</option>
<option value="Somalia (+252)">Somalia (+252)</option>
<option value="South Africa (+27)">South Africa (+27)</option>
<option value="South Korea (+82)">South Korea (+82)</option>
<option value="South Sudan (+211)">South Sudan (+211)</option>
<option value="Spain (+34)">Spain (+34)</option>
<option value="Sri Lanka (+94)">Sri Lanka (+94)</option>
<option value="St. Lucia (+1)">St. Lucia (+1)</option>
<option value="Sudan (+249)">Sudan (+249)</option>
<option value="Suriname (+597)">Suriname (+597)</option>
<option value="Swaziland (+268)">Swaziland (+268)</option>
<option value="Sweden (+46)">Sweden (+46)</option>
<option value="Switzerland (+41)">Switzerland (+41)</option>
<option value="Syria (+963)">Syria (+963)</option>
<option value="Taiwan (+886)">Taiwan (+886)</option>
<option value="Tajikistan (+992)">Tajikistan (+992)</option>
<option value="Tanzania (+255)">Tanzania (+255)</option>
<option value="Thailand (+66)">Thailand (+66)</option>
<option value="The Bahamas (+1)">The Bahamas (+1)</option>
<option value="The Gambia (+220)">The Gambia (+220)</option>
<option value="Timor-Leste (+670)">Timor-Leste (+670)</option>
<option value="Togo (+228)">Togo (+228)</option>
<option value="Tokelau (+690)">Tokelau (+690)</option>
<option value="Tonga (+676)">Tonga (+676)</option>
<option value="Trinidad and Tobago (+1)">Trinidad and Tobago (+1)</option>
<option value="Tunisia (+216)">Tunisia (+216)</option>
<option value="Turkey (+90)">Turkey (+90)</option>
<option value="Turkmenistan (+993)">Turkmenistan (+993)</option>
<option value="Turks and Caicos Islands (+1)">Turks and Caicos Islands (+1)</option>
<option value="Tuvalu (+688)">Tuvalu (+688)</option>
<option value="Uganda (+256)">Uganda (+256)</option>
<option value="Ukraine (+380)">Ukraine (+380)</option>
<option value="United Arab Emirates (+971)">United Arab Emirates (+971)</option>
<option value="United Kingdom (+44)">United Kingdom (+44)</option>
<option value="United States (+1)">United States (+1)</option>
<option value="Uruguay (+598)">Uruguay (+598)</option>
<option value="US Virgin Islands (+1)">US Virgin Islands (+1)</option>
<option value="Uzbekistan (+998)">Uzbekistan (+998)</option>
<option value="Vanuatu (+678)">Vanuatu (+678)</option>
<option value="Vatican City (+39)">Vatican City (+39)</option>
<option value="Venezuela (+58)">Venezuela (+58)</option>
<option value="Vietnam (+84)">Vietnam (+84)</option>
<option value="Wallis and Futuna (+681)">Wallis and Futuna (+681)</option>
<option value="Yemen (+967)">Yemen (+967)</option>
<option value="Zambia (+260)">Zambia (+260)</option>
<option value="Zimbabwe (+263)">Zimbabwe (+263)</option>
</select>
Subscribe to:
Posts (Atom)
IE7 Issues Text Indent
Unfortunately IE 7 is still widespread among the users hence while theming we have to give special importance to the grea...
-
§ LR parsers can be constructed to recognize all programming language constructs for which CFG can be written. § LR parsing is no...
-
A switching circuit consists of a finite number of gates ,each of which can be in any one of the two conditions 0...
-
The CPU bus has multiplexed lines but the system bus has separate lines for each signal. (The multiplexed CPU ...