Friday, May 27, 2011

Remove whitespace from your ASP.NET page

In a normal webpage there is a lot of whitespace. We put it there in form of tabs and carriage-returns in order to make the document more maintainable and easier to read. But it has its price in terms of adding to the overall weight of the document in kilobytes and it takes longer for the browser to render a page with a lot of whitespace. This is especially true for IE6, which renders whitespace a lot slower than its counterparts.
The problem is, we don’t want to write html without whitespace. It would make it impossible to maintain. What we are looking for is an automatic way to filter the whitespace at runtime. In ASP.NET this is easy. You can override the page’s Render method and do the filtering in there. We also want to be able to turn the filtering on and off easily, because when we develop we often want to look at the rendered html code and make sense of it.
Here is an example that does just that. It overrides the render method of the page and is turned on/off in the web.config.
Implement this on the aspx page or even better on the master page if you use ASP.NET 2.0:
//Add this to the top of the page
    using
System.Configuration;
    using System.Web.UI;
    using System.Text.RegularExpressions;
//Overrides the Render method
    protected override void Render(HtmlTextWriter writer)
    {
        using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
        {
            base.Render(htmlwriter);
            string html = htmlwriter.InnerWriter.ToString();

            if ((ConfigurationManager.AppSettings.Get("RemoveWhitespace") + string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                html = Regex.Replace(html, @"(?<=[^])\t{2,}|(?<=[>])\s{2,}(?=[<])|(?<=[>])\s{2,11}(?=[<])|(?=[\n])\s{2,}", string.Empty);
                html = Regex.Replace(html, @"[ \f\r\t\v]?([\n\xFE\xFF/{}[\];,<>*%&|^!~?:=])[\f\r\t\v]?", "$1");
                html = html.Replace(";\n", ";");
            }

            writer.Write(html.Trim());
        }
    }
and add this to the web.config appsetting section:
"RemoveWhitespace" value="true"/>
It's as easy as that and the overhead is reasonable. I use this on the most of the websites I build and have never noticed any negative impact in any way.


Source : -http://madskristensen.net/post/Remove-whitespace-from-your-ASPNET-page.aspx

Wednesday, May 11, 2011

10 Highly Effective Free Ways of Generating Traffic

In this highly digital world, targeted traffic to your website could not be any more valuable. You can have the best, most accessible, beautiful designed website in the world... if no one visits it you might as well just take it down. Does this sound like the old "If a tree falls in the woods does anyone hear it" phrase? That is because it is not that far off.
If you have a huge advertising budget getting targeted traffic is not that difficult. There are countless tools available for identifying the right markets and you can simply write checks to your hearts desire. However most of us are placed in situations where we (or our clients) simply can not afford to spend tens of thousands of dollars on internet advertising.
Luckily, if you know the right strategies you can get plenty of targeted traffic with out spending any hard cash.

1. Build an E-mail List

Building an e-mail list is something that many of us have seemed to have forgotten about. It may be due to the association with spam, or that it has been around so long, or maybe social media and RSS seem like a better option. E-mail offers a very unique difference and advantage however. First you have the ability to send specific e-mails and messages to specific groups and segments of your audience (where RSS is an all or nothing approach), but additionally you tend to have a more captive audience which results in higher response and conversion rates.
RESOURCES

2. Focus on Organic Search

Organic Search Engine Optimization (SEO) has the capability to pull in large amounts of traffic with out having to spend a dime (in theory). Organic search is simply the unpaid listing of websites that show up when someone performs an internet search on a site such as Google, Yahoo or Bing. With 80% of all transactions starting with an internet search, not only do you have an audience that is ready to buy... it has the potential to bring in more traffic that almost any other approach available.
While we would all like to get more organic traffic it often is easier said than done. It is important to keep in mind that there is no way to trick your way to good rankings. The best practice is always to create high quality valuable content and ensure your website is built in a way that is search engine friendly. Keep in mind that when you are focusing on organic traffic getting high quality links with targeted anchor text tends to be most effective (for example, DIY Solar Energy)
RESOURCES

3. Social Media

Social Media is the use of employing sites and media that allow you to connect with other people on a social level. The common examples would be Twitter, YouTube, Facebook and Linkedin. These sites let you connect and converse with other users who have similar interests as you. Because all websites have some overarching theme or topic, you can connect with people who are also interested in the topic. This gives you the opportunity to build awareness of your site/product/service with your audience on a personal level which is much more effective than on a push media level.
An important note about social media. Make sure anything you do, publish or say on these networks is done in a way that actually adds value to someones day. If you are simply signing up to spam links to your site you are likely to have sub-par results.
RESOURCES

4. Develop Some Public Relations

With so much focus on digital media public relations has lost a lot of the attention that it used to hold. Public relations is a valuable part of any marketing mix and it is an approach to building awareness and traffic that shouldn't be ignored. Especially considering it can be a low cost (or no cost) solution. There really are two areas in which we can benefit from public relations, through traditional forms of media and new forms of media.
While there are many different facets of PR, where you stand to gain a lot of new traffic is by having stories and articles written about your website.

Offline

Back before the internet became what it is today, companies would send a small one page write up with "news worthy" content regarding their company to any relevant media sources. These went out to newspapers, magazines, journals, etc... This write up was called a "press release" and simply covered the "who, what, when, why and how" of the story. Despite the fact that the internet is changing the way people consume news, it is still an effective way of building awareness about your website and/or company.
There have been plenty of studies and reports that show a direct correlation between traditional media mentions and website traffic. Even if your website isn't listed in the article you will find more branded searches for your website (and thus more traffic). If you know that you are going to be covered you can also try and capitalize on the increase in traffic and offer special discounts or personalized messages.
The process is fairly simple. Round up any related publications and look for the news contacts, almost every publication will have an e-mail where you can submit news. Write up a short press release and distribute it to the list you created previously. Don't be afraid to call up the media and pitch the story to them a few days after you have sent the release.

Online

This process doesn't have to be limited to offline publications. There are lots of industry blogs and websites that regularly post content and news to an audience consisting of your target market. While the concept is similar (get an online publication or blog to talk about you, your product, your company, etc..) it tends to be slightly different in approach. In most cases getting articles and news published can be a bit trickier as you are not always working with professional journalists who always need that next story.
When pitching stories to bloggers or online publications you may need to spend more time developing a relationship with the authors first. Additionally finding a list of relevant blogs can be a bit more tricky and require more searching. The more open and honest you are about the situation the better your results will be. It is unnecessary to write a formal press release (and ineffective), focus on starting a conversation with the author instead.
RESOURCES

5. Add Value to Other Sites

Ok "Web 2.0" might be a cliche term, but there are a countless websites that thrive on user participation and contribution. I assure you that there are some related to your industry or that consist of your target market, as people naturally want to connect and discuss things that are important to them. Some industries and topics may be harder to find than others, but if you are listening there are people talking.
Once you have found these types of sites, take a little bit of time every week to add value to them through participation. Over time the users will begin to become familiar with you and trust you. By offering your knowledge you will build awareness, good will and trust for your company/website/profession. Additionally most of these sites will even let you have a profile or signature that can contain a link (or several) to your website so you don't have to be so direct about your motives.
The more you participate and the more you contribute the more you will get out of this technique.

6. Get Others Involved

Sometimes the best way to build awareness and traffic is through word of mouth. Word of mouth is actually one of the most effective forms of marketing online and off. Not far behind word of mouth in terms of effectiveness is celebrity endorsement. This method can drive traffic to your website by using both of these proven techniques. When you get other people involved in your website (either as guest bloggers, giving them an interview, etc...) you are doing two very powerful things. First you are actually giving people a small portion of ownership in what you are doing. When they invest the time to contribute and assist the site they buying into the idea that it is worth their time and effort. Because of this they are going to be much more likely to want your website to succeed and thus tell other people. If nothing else they will likely link to their contribution and tell people about it.
Additionally by having a well known figure contributing to your website you are getting their endorsement and it can boost your credibility significantly (even to the point of matching their own). This subconsciously will resonate with users and put the site at a higher status than they would previously, making them much more likely to share your site, contribute to the site and return for future visits.

7. Syndicate Your Content

Chances are if you are looking for more traffic there are at least a handful of other sites on the web that cover the same (or similar) subjects that you are. By creating high quality content you can offer a win/win situation. Approach popular websites and offer to publish (or syndicate) your articles on their site. They win by providing relevant content to their readers with out having to perform the work of creating it and you can build awareness / traffic to your site through an article byline.
If you can't find any websites that will bite you could always submit your articles to article directory sites. They often have huge mailing lists on various topics and tend to rank fairly well themselves.

8. Contests For Your Services

Contests have always been a great way to build awareness and interest. After all who doesn't like wining something for free? Since we are talking about free ways to generate traffic purchasing an item to give away is out of the picture. Sure you might be able to find something you already have to give away but how likely is that? Instead offer up your expertise. Chances are you have skills or knowledge that is valuable to other people or companies. By offering a contest for the services you don't have to spend any additional capital and build awareness for all of those people who previously didn't know about your expertise but could use your help.
This is a perfect time to build your e-mail list. Ask those who are signing up for your contest if they would like to be entered into your newsletter for future opportunities and giveaways.
If you don't want to do a contest you could also do a free seminar or webinar, both of which can drive a lot of traffic and attention to your site as well.

9. Be Remarkable

Supreme marketing guru Seth Godin often talks about the importance of being remarkable. The idea is that if you are "the best in the world" at something it will naturally market for you. An important part of achieving this status is picking a very specific and narrow niche or specialty. If you have a content focused website, what very specific topic can you cover that you can do better than anyone else in the marketplace? If you run a service company, what very narrow and specific niche can you server better than any of the other companies in the market?
By focusing your attention on becoming the best at this narrow specialty you will become remarkable and an expert. Your demand will increase dramatically and people will start finding your site naturally. This actually is more effective and will generate more traffic than if you were to try and be "good" in a market that is already saturated with those who can do a better job than you.
RESOURCES

10. Start a Group or Organization

Through out human history we have always desired a sense of belonging and community.It doesn't take much looking to find a group of people who are interested in the same things that you are. Start a weekly meet up, tweet up, chat up (if it is virtual), forum, digest, etc... that gets the group of people together to talk and discuss the issues. You would be surprised at how quickly a group like that can grow. As the founder and head of the group or organization you will receive a lot of notoriety and interest. It will also give you great opportunities to have links and advertisements for your company or website through out areas in which members interact.

Conclusion

There are lots of different ways to drive traffic to your website with out spending much (or any) money. Sometimes they are more effective than paid methods. The general rule of thumb though is that traffic tends to be high involvement and low cost, or low involvement and high cost. Search Marketing is a good example of this - where pay per click can get you traffic very quickly and with out much in terms of time investment, organic rankings can take significantly more work and take much longer but at a much lower cost.
It is important to understand what techniques, tactics and strategies are going to be most effective for any given situation. Blindly trying them all is not going to work very well, take the time to think through and plan your approach in building traffic.


Search engine optimization (SEO)- Things todo and not todo

Search engine optimization (SEO) is the process of improving the volume and quality of traffic to a web site from search engines via "natural" ("organic" or "algorithmic") search results for targeted keywords. In this article find out how to do basic SEO, code search engine friendly pages and how to do a basic promotion of your site.

Things to do
  • Keywords in URL
    For example http://www.aboutdoghealth.org/ use whole words – keywords to best describe your site. Don’t rely on this if you don’t have keywords in other parts of your site.
  • Keywords in <title> tag
    This shows search results as your page title, so this is one of the most important things and it shouldn’t be long 5-6 words max, and use keyword at the beginning.
  • Keywords in anchor texts
    Also very important, especially for the anchor text, because if you have the keyword in the anchor text in a link from another site, this is regarded as getting a vote from this site not only about your site in general, but about the keyword in particular.
  • Keywords in headings (<H1>, <H2>, etc. tags)
    One more place where keywords count a lot. But beware that your page has actual text about the particular keyword.
  • Keywords in the beginning of a document
    While coding your page put your main content before side bar. Because this also counts, though not as much as anchor text, title tag or headings
  • Keywords in <alt> tags
    Spiders don't read images but they do read their textual descriptions in the <alt> tag, so if you have images on your page, fill in the <alt> tag with some keywords about them.
  • Anchor text of inbound links
    This is one of the most important factors for good rankings. It is best if you have a keyword in the anchor text but even if you don't, it is still OK.
  • Origin of inbound links
    It is important if the site that links to you is a reputable one or not. Generally sites with greater Google PR are considered reputable and the .edu and .gov sites are the most reputable
  • Links from similar sites
    Having links from similar sites is very, very useful. It indicates that the competition is voting for you and you are popular within your topical community.
  • Metatags
    Metatags are becoming less and less important but if there are metatags that still matter, these are the <description> and <keywords> ones.
  • Unique content
    Having more content (relevant content, which is different from the content on other sites both in wording and topics) is a real boost for your site's rankings.
  • Frequency of content change
    Frequent changes are favored. It is great when you constantly add new content but it is not so great when you only make small updates to existing content.
  • Site Accessibility
    Another fundamental issue, which that is often neglected. If the site (or separate pages) is unaccessible because of broken links, 404 errors, password-protected areas and other similar reasons, then the site simply can't be indexed.
  • Sitemap
    It is great to have a complete and up-to-date sitemap, spiders love it, no matter if it is a plain old HTML sitemap or the special Google sitemap format.
Things not to do
  • Keyword stuffing
    Any artificially inflated keyword density (10% and over) is keyword stuffing and you risk getting banned from search engines.
  • Keyword dilution
    When you are optimizing for an excessive amount of keywords, especially unrelated ones, this will affect the performance of all your keywords and even the major ones will be lost (diluted) in the text.
  • Single pixel links
    when you have a link that is a pixel or so wide it is invisible for humans, so nobody will click on it and it is obvious that this link is an attempt to manipulate search engines.
  • Cross-linking
    Crosslinking occurs when site A links to site B, site B links to site C and site C links back to site A
  • Duplicate content
    When you have the same content on several pages on the site, this will not make your site look larger because the duplicate content penalty kicks in. To a lesser degree duplicate content applies to pages that reside on other sites but obviously these cases are not always banned
  • Doorway pages
    Creating pages that aim to trick spiders that your site is a highly-relevant one when it is not, is another way to get the kick from search engines.
  • Cloaking
    Cloaking is another illegal technique, which partially involves content separation because spiders see one page (highly-optimized, of course), and everybody else is presented with another version of the same page.
  • Invisible text
    This is a black hat SEO practice and when spiders discover that you have text specially for them but not for humans, don't be surprised by the penalty.
  • Illegal Content
    Using other people's copyrighted content without their permission or using content that promotes legal violations can get you kicked out of search engines.
  • Flash
    Spiders don't index the content of Flash movies, so if you use Flash on your site, don't forget to give it an alternative textual description. And also don’t have just flash home page without HTML one.
  • Frames
    Frames are very bad for SEO. Avoid using them unless really necessary.
  • Redirects (301 and 302)
    When not applied properly, redirects can hurt a lot – the target page might not open, or worse – a redirect can be regarded as a black hat technique, when the visitor is immediately taken to a different page.
  • Bans in robots.txt
    If indexing of a considerable portion of the site is banned, this is likely to affect the nonbanned part as well because spiders will come less frequently to a “noindex” site.
  • Session IDs
    This is even worse than dynamic URLs. Don't use session IDs for information that you'd like to be indexed by spiders.


Tuesday, April 26, 2011

Object Oriented Programming Concepts

Object-oriented problem solving approach is very similar to the way a human solves daily problems. It consists of identifying objects and how to use these objects in the correct sequence to solve the problem. In other words, object-oriented problem solving can consist of designing objects whose behavior solves a specific problem. We can use following approaches

Abstraction
Abstraction is the process or result of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose. For example, abstracting a leather soccer ball to a ball retains only the information on general ball attributes and behaviour. Similarly, abstracting happiness to an emotional state reduces the amount of information conveyed about the emotional state. Computer scientists use abstraction to understand and solve problems and communicate their solutions with the computer in some particular computer language.



Polymorphism

Polymorphism is a simple concept that you understand right now, as it is prevalent through life. You are a person, which person is a base type and you are a more specific representation of that type. There are many people that inherit that type, of which you are a concrete implementation of that type: you have your own beliefs, attributes, and qualities that go beyond just a general person. For instance, we all have a blood type, shoe size, arm length, and many other properties. But we each add our own implementation to the person interface.

You drive an automobile, which this type has properties like wheel size, engine size, gas tank size, and other properties. The automobile you drive is a concrete implementation of the automobile interface. It has additional features, like sliding doors, logo type, cd changer slot count, moon roof lever location, or other various properties that are specific to the make/model of the car. In addition, automobile may have certain behaviors like open/close door, open trunk, turn wheel, and other behaviors that would be specific to an automobile.

In OO programming, using the automobile example, Automobile would be the base class, and each automobile manufacturer would have its own implementation. For instance, Honda has V-Tec technology, which is in its own implementation. Volvo uses diesel engines, which is the TDI technology. More importantly, you may add an added level of detail between automobile and the make/model implementation, such as Car, Truck, or Suv supertypes, to provide more relevant information.

Encapsulation

Think of encapsulation as a black box; data is sent to a method, a lot of work goes on using the data, of which you don't know or care about. An output is returned to the caller. That is the process of encapsulation, or information hiding.

Thursday, April 21, 2011

Export data from XML to SQL Server

Some times  we need that we want to transfer the data from a XML file to the sql server.I know that there are several ways to do that.But this methods is quite simple and sort and obviously very fast.

Only we need to read xml file into a dataset then simply write this data to SQL server by SQLBulkCopy Command.And you are done.


        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath("HotelList.xml"));       
        DataTable dt = ds.Tables[0];
       // dt.Columns.Remove("HotelID");
       // dt.Columns.Remove("HotelFileName");
       // dt.Columns.Remove("HotelName");
       // dt.Columns.Remove("CityID");
       // dt.Columns.Remove("CityFileName");
       // dt.Columns.Remove("CityName");
       // dt.Columns.Remove("StateID");
       // dt.Columns.Remove("StateFileName");
       // dt.Columns.Remove("StateName");
       //dt.Columns.Remove("CountryCode");
       // dt.Columns.Remove("CountryFileName");
       // dt.Columns.Remove("CountryName");
       // dt.Columns.Remove("FolderName");
       // dt.Columns.Remove("FileName");
       // dt.AcceptChanges();
        string strconnection = "Data Source=Shert-PC;Initial Catalog=hotel;Integrated Security=True";
        SqlConnection con = new SqlConnection(strconnection);
        con.Open();
        SqlBulkCopy sbc = new SqlBulkCopy(con);
        sbc.DestinationTableName = "tbl_xml"; 
        sbc.BulkCopyTimeout = 100000000;
        sbc.WriteToServer(dt);
        con.Close();

Wednesday, April 20, 2011

Prevent Sql Injection in ASP.Net

A successful SQL injection attack enables a malicious user to execute commands in your application's database by using the privileges granted to your application's login. The problem is more severe if your application uses an over-privileged account to connect to the database. For example, if your application's login has privileges to eliminate a database, then without adequate safeguards, an attacker might be able to perform this operation.
Common vulnerabilities that make your data access code susceptible to SQL injection attacks include:
    * Weak input validation.
    * Dynamic construction of SQL statements without the use of type-safe parameters.
    * Use of over-privileged database logins.
To prevent the sql injection please copy and paste the following code into your app_code folder.And add a handler into your web.config files as follows-

<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0,  Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>      
    <add name="InjectFilter" type="Inject.InjectFilter"/>
</httpModules>

and put the fololowing code into a class.
And your code is ready to use no external function or code to validate each input ot whatever you can use this in any new website or even old sites without making too much changes.

Happy Coding!!!!!!!!!!!!!!

 In C#
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace Inject
{
    [Serializable]
    public class InjectFilter : IHttpModule
    {
        //Defines the set of characters that will be checked.
        //You can add to this list, or remove items from this list, as appropriate for your site
        public static string[] blackList = {
        ";--",  "/*", "*/", "@@","/script","xp_", "b.js", " char "," nchar "," varchar ", " nvarchar ", " alter ",
        "cast(",   " declare ",   "delete from",   "drop table",   "exec(",  "execute ",   "insert into",  "sysobjects ",
        "syscolumns ",  " update ", "<script>"
    };
        public void Dispose()
        {
            //no-op
        }
        //Tells ASP.NET that there is code to run during BeginRequest
        public void Init(HttpApplication app)
        {
            app.BeginRequest += app_BeginRequest;
        }
        //For each incoming request, check the query-string, form and cookie values for suspicious values.
        private void app_BeginRequest(object sender, EventArgs e)
        {
            HttpRequest Request = (sender as HttpApplication).Context.Request;
            foreach (string key in Request.QueryString)
            {
                CheckInput(Request.QueryString[key]);
            }
            foreach (string key in Request.Form)
            {
                CheckInput(Request.Form[key]);
            }
            foreach (string key in Request.Cookies)
            {
                CheckInput(Request.Cookies[key].Value);
            }
        }
        //The utility method that performs the blacklist comparisons
        //You can change the error handling, and error redirect location to whatever makes sense for your site.
        private void CheckInput(string parameter)
        {
            for (int i = 0; i <= blackList.Length - 1; i++)
            {
                if ((parameter.IndexOf(blackList[i], StringComparison.OrdinalIgnoreCase) >= 0))
                {//
                    //Handle the discovery of suspicious Sql characters here
                    //
                    //generic error page on your site                  

                    if (HttpContext.Current.Request.RawUrl.ToLower().IndexOf("/admin") < 0 && HttpContext.Current.Request.RawUrl.ToLower().IndexOf("/merchant") < 0 && HttpContext.Current.Request.RawUrl.ToLower().IndexOf("/cutesoft_client")<0)
                    {
                        HttpContext.Current.Response.Redirect("~/Default.aspx");
                    }
                }
             }
        }
    }
}

Monday, April 18, 2011

rename file if already exists in database while uploading

I like to use the the way windows allows for unique file or folders: New Folder --> New Folder (2) if the folder exists.
string fileName = /* your file path */
string newFileName = fileName;
int count = 2;
while (System.IO.File.Exists(newFileName))
{
    if(fileName.EndsWith("\\")) fileName = fileName.Remove(fileName.Length-1);

    string dir = fileName.Substring(0,fileName.LastIndexOf("\\"));
    string fName = fileName.Replace(dir, "");
    string name = fName.Split('.')[0];
    string ext = fName.Split('.')[1];
    newFileName = dir + string.Format("{0} ({1}).{2}", name, count.ToString(), ext);
    count++;
}
// Here you would use your unique newFileName
I hope I understood you correctly

How To Add A Background Image In Gmail ?

You mean to add image in your email.if yes then you need to
1)Go to settings
2)Select Labs
3)Enable “Inserting images”
4)Save changes.

Now if you wish to add image in signature.follow these steps
1)Go to settings
2)under the general tab find Signature
3)For inserting an Image in the signature.first you have to upload the image in free image hosting sites.

for eg:go to imageshack.us. browse for the image you want to upload.and click upload.after its uploaded,copy the direct link

4)There is an image icon in the signature box.click on that and paste the direct link you copied from imageshack.us

That it. have a nice day

Create HTML Signatures Right Inside Gmail

Gmail Signatures Step-by-Step

Step 1: Go to Gmail Settings –> Labs and enable “Canned Responses” as well as “Inserting Images.”

Step 2: Compose a new message in Gmail and create a signature just like you would compose any other email message. Be creative!

You can either upload logos and icons* from the computer or use images that are already on the web. I suggest the former style as that will permanently embed the image into your email signature.

[*] You can find images of icons through Google Image Search. Go to Advanced options under image search and type 12 for height and width (use 16px if you are looking to add slightly bigger icons). While optional, you may also select the filetype as PNG or GIF for transparent backgrounds - see example.

Step 3: Once your happy with the formatting and layout of your new “HTML signature,” go to the Canned Response menu and Save – give some logical name like “Personal” for a signature that you want to attach to your personal emails

String.PadLeft Method

Returns a new string of a specified length in which the beginning of the current string is padded with spaces or with a specified Unicode character.
This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.


PadLeft(Int32) Returns a new string that right-aligns the characters in this instance by padding them with spaces on the left, for a specified total length.
PadLeft(Int32, Char)    Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a specified total length.
Example :- 1.ToString().PadLeft(4,'0')
Will show the results as "0001"
Source : -http://msdn.microsoft.com/en-us/library/system.string.padleft.aspx