Thursday, 28 February 2013

Lesson 4

A web site design and layout gives first impression about your site. There are sites which are too fancy and regular net surfers will just reach on those sites and will come out even without creating a single click.
Search Engines are very smart but after all they are software and not human being who will read the content of their interest. If you make your site too complicated then Search Engine would not be able to parse the content of your site properly and finally indexing would not be efficient which will result in a low rank.
The actual page content should have a keyword density of about 10% and should weigh in at about 200 words - but there are as many opinions about this as there are SEO experts. Some say keyword density should be 5% and some say it should be 20%. 10% works for me.
Here are few guidelines which should be considered while designing a web page.
  • You should have more text content than HTML elements.
  • No frames. They are the enemies of Search Engines and Search Engines are Enemies of Frames.
  • No ads if possible. Because most of the ads uses Java Script which is not advised to be used.
  • No JavaScript. If you need JavaScript, call it from an external file rather than dumping the code in the HTML file. JavaScript drop down menus prevent spiders from crawling beyond your homepage. If you use them, be sure to include text links at the bottom of the page.
  • Nothing that does not fit perfectly into the page topic; There should be no doubt in the search engine's mind (or in he user's mind) what your page is about.
  • No unnecessary directories. Keep your files as close to the root as possible.
  • No fancy stuff (Flash, Splash, Animated Gifs, Rollovers etc.) unless absolutely necessary.

Lesson 4

One of the simplest methods to improve your search engine optimization is to look at the way you name your files. Before writing this tutorial I did lot of research on file names and found that search engines like Google give too much importance to file names. You should think what are you going to put in your web page and then give a relevant file name to this page.
Just try giving any keyword in Google search engine and you will find file names highlighted with the keyword you have given. So it simply proves that your file name should have appropriate keyword.

File Naming Style:

  • The filename should preferably be short and descriptive. It's always good to use same keywords in file name as well as in page title.
  • Don't use file names like service.htm or job.htm. But use actual service name in your file name like computer-repairing.htm
  • Don't use more than 3-4 words in file name and separate them with hyphens rather than underscores. Try to use 2 keywords if possible.

File Name Example:

Here are some file names which should be preferred from SEO as well as from user point of view.
slazenger-brand-balls.html
wimbledon-brand-balls.html
wilson-brand-balls.html
Notice that keywords are separated by hyphens rather than underscores. Google sees file names as follows:
seo-relevant-filename as seo relevant filename(good)
But Google sees
seo_relevant_filename as seorelevantfilename (not good)

File Extension:

It should be noticed that .html, .htm and .php and any other extension do NOTHING for your visitors, and they are simply a means of offloading some of the work of configuring your webserver properly onto your visitors. In effect you are asking your site vistors to tell your webserver HOW to produce the page, not which one?
Many Web masters think that its a good idea to use filename without using extension. It may help you but not a whole lot.

URL Sub-Directory Name:

From Search Engine Optimization point of view URL sub-directory name hardly matters. You try giving any keyword in any search and you will not find any sub-directory name matching with your keywords. But from user point of view you should keep very much abbreviated sub-directory name.

Key Point:

Finally, I will suggest to keep the following points in mind before naming your files:
  • Use web page file name short, simple, descriptive and relevant to page content.
  • Try to use maximum 3-4 keywords in your file name and these keywords should be appeared in your web page title as well.
  • Separate all keyword with hyphen rather than with underscore.
  • Keep your sub directories name as shorter as possible.
  • Keep the file size fewer than 101K though because Google chops almost everything above that.

Lesson 3

When you start thinking of doing a business through internet, first thing which you think about is your web site domain name. Before you choose a domain name you should consider the followings:
  • Who would be your target audience?
  • What you intend to sell to them. Is it a tangible item or just text content?
  • What will make your business idea unique or different than everything else that is already on the market?
Many people think it is important to have keywords in a domain. Keywords in the domain name are usually important, but it usually can be done while keeping the domain name short, memorable, and free of hyphens.
Using keywords in your domain name give you a strong competitive advantage over your competitors. Having your keywords in your domain name can increase click through rates on search engine listings and paid ads as well as make it easier to Using your keywords in get keyword rich descriptive inbound links.
Avoid buying long, and confusing domain names. May people separate the words in their domain names using either dashes or hyphen. In the past the domain name itself was a significant ranking factor but now search engines have advanced it is not very significant factor anymore.
Keep two to three words in your domain name it will be more memorable. Some of the most memorable websites do a great job of branding by creating their own word. Few examples are eBay, Yahoo!, Expedia, Slashdot, Fark, Wikipedia, Google...
You should be able to say it over the telephone once and the other person should know how to spell it and they should be able to guess about what you sell.

Key Points:

Finally, you should be able to answer yourself for the following questions:
  • Why do you want to build your website? Why should people buy off your site and not from other Site? What makes you different from others?
  • Who are your target audience and what you intend to sell to them?
  • List 5 - 10 websites which you thing, they are they amazing. Now think why are they amazing?
  • Create 5 different domain names. Make at least 1 of them funny. Tell them to a half dozen people and see which ones are the most memorable. You will get more honest feedback if the people do not know you well.
  • Buy your domain name which is more catchy, memorable and relevant to your business.

Lesson 2


SEO techniques are classified into two broad categories:
  1. Techniques that search engines recommend as part of good design referred to as White Hat SEO, and
  2. Techniques that search engines do not approve and attempt to minimize the effect of referred to as Black Hat or spamdexing.
White Hat SEO:
An SEO tactic, technique or method is considered as White Hat if it follows the followings
  • If it conforms to the search engine's guidelines.
  • If it does not involves any deception.
  • It ensures that the content a search engine indexes and subsequently ranks is the same content a user will see.
  • It ensures that a Web Page content should have been created for the users and not just for the search engines.
  • It ensures the good quality of the web pages
  • It ensures the useful content available on the web pages
Always follow a White Hat SEO tactic and don't try to fool your site visitors. Be honest and definitely you will get something more.
Next chapter onward we will put light on White Hap SEO techniques. The WHST are very simple and can be done without investing much cost.
Black Hat or Spamdexing:
An SEO tactic, technique or method is considered as Black Hat or Spamdexing if it follows the followings
  • Try to improve rankings that are disapproved of by the search engines and/or involve deception.
  • Redirecting users from a page that is built for search engines to one that is more human friendly.
  • Redirecting users to a page that was different from the page the search engine ranked.
  • Serving one version of a page to search engine spiders/bots and another version to human visitors. This is called Cloaking SEO tactic.
  • Using Hidden or invisible text or with the page background color, using a tiny font size or hiding them within the HTML code such as "no frame" sections.
  • Repeating keywords in the Meta tags, and using keywords that are unrelated to the site's content. This is called Meta tag stuffing.
  • Calculated placement of keywords within a page to raise the keyword count, variety, and density of the page. This is called Keyword stuffing .
  • Creating low-quality web pages that contain very little content but are instead stuffed with very similar key words and phrases. These pages are called Doorway or Gateway Pages
  • Mirror web sites by hosting multiple web sites all with conceptually similar content but using different URLs.
  • Creating a rogue copy of a popular web site which shows contents similar to the original to a web crawler, but redirects web surfers to unrelated or malicious web sites. This is called Page hijacking.
Always be away to adopt any of the above Black Hat tactic to improve the rank of your site. Search engines are smart enough to identify all the above proprieties of your site and ultimately you are not going to get anything.

Sending SMS from the webpage

Introduction

In this article we will see an example of sending sms through the way2sms account. There are two pages in the demo

1. login.aspx 
2. Sms.aspx

This is the login.aspx where you have to provide your way2sms username and password

NOTE: If you don't have account in way2sms, before using this demo you have to create account in way2sms.com

1.gif

protected
void btnconnect_Click(object sender, EventArgs e){    Session["id"] = txtmobileno.Text;    Session["pw"] = txtpw.Text;    Response.Redirect("send.aspx");}
Send.aspx

In this page two functions are created

1. Connect() this function will connect and authenticate your id and password
2. Sendsms(): If you are successfully connected they you will get the following page and you can send sms now


2.gif
Send.aspx.cs

using
System;using System.Data;using System.Configuration;using System.Collections;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 System.IO;using System.Net;using System.Text;using System.Text.RegularExpressions;
public
partial class send : System.Web.UI.Page{    string mbno, mseg, ckuser, ckpass;    private HttpWebRequest req;    private CookieContainer cookieCntr;    private string strNewValue;    public static string responseee;    private HttpWebResponse response; 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["id"] == null && Session["pw"] == null)
        {
            Server.Transfer("login.aspx");
        }
        connect();
 
        try
        {
            lblError.Text = "";
            lblError.Visible = false;
            if (!(IsPostBack))
            {
                btnSend.Attributes.Add("onclick", "return Validate('" + txtTo.ClientID + "','" + txtMessage.ClientID + "');");
                txtMessage.Attributes.Add("onchange", "TextChange('" + txtMessage.ClientID + "','" + lblLeft.ClientID + "');");
                txtMessage.Attributes.Add("onkeyup", "TextChange('" + txtMessage.ClientID + "','" + lblLeft.ClientID + "');");
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
            lblError.Visible = true;
        }
       
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {
            mbno = txtTo.Text;
            mseg = txtMessage.Text;
 
            sendSms(mbno, mseg);
            txtTo.Text = "";
            txtMessage.Text = "";
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
            lblError.Visible = true;
        }
    }
    public void connect()
    {
        ckuser = Session["id"].ToString();
        ckpass = Session["pw"].ToString();
 
        try
        {
            this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com/auth.cl");
 
            this.req.CookieContainer = new CookieContainer();
            this.req.AllowAutoRedirect = false;
            this.req.Method = "POST";
            this.req.ContentType = "application/x-www-form-urlencoded";
            this.strNewValue = "username=" + ckuser + "&password=" + ckpass;
            this.req.ContentLength = this.strNewValue.Length;
            StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
            writer.Write(this.strNewValue);
            writer.Close();
            this.response = (HttpWebResponse)this.req.GetResponse();
            this.cookieCntr = this.req.CookieContainer;
            this.response.Close();
            this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//jsp/InstantSMS.jsp?val=0");
            this.req.CookieContainer = this.cookieCntr;
            this.req.Method = "GET";
            this.response = (HttpWebResponse)this.req.GetResponse();
            responseee = new StreamReader(this.response.GetResponseStream()).ReadToEnd();
            int index = Regex.Match(responseee, "custf").Index;
            responseee = responseee.Substring(index, 0x12);
            responseee = responseee.Replace("\"", "").Replace(">", "").Trim();
            this.response.Close();
 
            pnlsend.Visible = true;
            lblErrormsg.Text = "connected";
        }
        catch (Exception)
        {
            lblErrormsg.Text = "Error connecting to the server...";
            Session["error"] = "Error connecting to the server...";
            Server.Transfer("login.aspx"); 
        }
    }
    public void sendSms(string mbno, string mseg)
    {
        if ((mbno != "") && (mseg != ""))
        {
            try
            {
                this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//FirstServletsms?custid=");
                this.req.AllowAutoRedirect = false;
                this.req.CookieContainer = this.cookieCntr;
                this.req.Method = "POST";
                this.req.ContentType = "application/x-www-form-urlencoded";
                this.strNewValue = "custid=undefined&HiddenAction=instantsms&Action=" + responseee + "&login=&pass=&MobNo=" + this.mbno + "&textArea=" + this.mseg;
 
                string msg = this.mseg;
                string mbeno = this.mbno;
 
                this.req.ContentLength = this.strNewValue.Length;
                StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
                writer.Write(this.strNewValue);
                writer.Close();
                this.response = (HttpWebResponse)this.req.GetResponse(); 
                this.response.Close();
                lblErrormsg.Text = "Message Sent..... " + mbeno + ": " + msg;
            }
            catch (Exception)
            {
                lblErrormsg.Text = "Error Sending msg....check your connection...";
            }
        }
        else
        {
            lblErrormsg.Text = "Mob no or msg missing";
        }
    }
 
    protected void logout_Click(object sender, EventArgs e)
    {
        //logout
        Session["id"] = null;
        Session["pw"] = null;
        Session["error"] = null;
        Server.Transfer("login.aspx");
    }
}

Friday, 15 February 2013

Date Time Formate

-->


In SQL Server used Cast or Convert function to Format DateTime value or column into a specific date format.Both function are used to convert datetime to varchar or string.

CAST function Syntax: CAST(expression as data_type)

Let's convert current date time to varchar

select cast(getdate() as varchar)

CONVERT function is used to change or convert the DateTime formats.By using convert
function you can get only Date part or only Time part from the datetime.

CONVERT Function Syntax- 
 CONVERT(data_type,expression,date Format style)

Let's take Sql Server DateTtime styles example:



Format

Query


USA mm/dd/yy


select convert(varchar, getdate(), 1)

ANSI yy.mm.dd


select convert(varchar, getdate(), 2)

British/French dd/mm/yy

select convert(varchar, getdate(), 3)


German dd.mm.yy

select convert(varchar, getdate(), 4)


Italian dd-mm-yy


select convert(varchar, getdate(), 5)

dd mon yy


select convert(varchar, getdate(), 6)

Mon dd, yy

select convert(varchar, getdate(), 7)


USA mm-dd-yy


select convert(varchar, getdate(), 10)

JAPAN yy/mm/dd


select convert(varchar, getdate(), 11)

ISO yymmdd

select convert(varchar, getdate(), 12)


mon dd yyyy hh:miAM

(or PM)

select convert(varchar, getdate(), 100)

mm/dd/yyyy

select convert(varchar, getdate(), 101)


yyyy.mm.dd

select convert(varchar, getdate(), 102)


dd/mm/yyyy


select convert(varchar, getdate(), 103)

dd.mm.yyyy


select convert(varchar, getdate(), 104)

dd-mm-yyyy

select convert(varchar, getdate(), 105)


dd mon yyyy

select convert(varchar, getdate(), 106)


Mon dd, yyyy

select convert(varchar, getdate(), 107)


hh:mm:ss

select convert(varchar, getdate(), 108)


Default +
milliseconds mon dd yyyy hh:mi:ss:mmmAM (or PM)


select convert(varchar, getdate(), 109)

mm-dd-yyyy

select convert(varchar, getdate(), 110)


yyyy/mm/dd


select convert(varchar, getdate(), 111)

yyyymmdd


select convert(varchar, getdate(), 112)

Europe default +
milliseconds dd mon yyyy hh:mm:ss:mmm(24h)


select convert(varchar, getdate(), 113) or
select convert(varchar, getdate(),
13)

hh:mi:ss:mmm(24h)

select convert(varchar, getdate(), 114)