Programming

    How to Display Google Maps Using C#.Net

    Design:
    Open->VS2008/10->FileàNewàprojectàselect Window form Applicationàok
    Create design using controls like Textboxes, Button, Labels and webBrowser1
    Coding
    In search Button Click
    private void button1_Click(object sender, EventArgs e)
            {
                StringBuilder url = new StringBuilder();
                url.Append("https://maps.google.com/maps?q=");

                if (textBox1.Text == "")
                {
                    MessageBox.Show("Enter the Location");
                }
                else if (textBox2.Text == "")
                {
                    MessageBox.Show("Enter the Criteria");
                }
                else
                {
                    url.Append(textBox1.Text + "," + "+");
                    url.Append(textBox2.Text + "," + "+");
                    webBrowser1.Navigate(url.ToString());
                }
            }



    Image Sliding Effect Using JavaScript

    Source Code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>GK DevelopmentS</title>

    <script language="JavaScript">

    <!--

    var slideimages=new Array()

    var slidelinks=new Array()

    function slideshowimages()

    {

    for (i=0;i<slideshowimages.arguments.length;i++)

    {

    slideimages[i]=new Image()

    slideimages[i].src=slideshowimages.arguments[i]

    }}

    function slideshowlinks()

    {

    for (i=0;i<slideshowlinks.arguments.length;i++)

    slidelinks[i]=slideshowlinks.arguments[i]

    }

    function gotoshow()

    {

    if(!window.winslide||winslide.closed)

    winslide=window.open(slidelinks[whichlink])

    else

    winslide.location=slidelinks[whichlink]winslide.focus()

    }

    //-->

    </script>

    </head>

    <body>

    <a href="javascript:gotoshow()">

    <img src="9.jpg" name="slide" border=0 width="600" height="400"></a>

    <script>

    <!--

    slideshowimages("9.jpg","10.jpg","11.jpg","12.jpg")

    slideshowlinks("http://www.bestsavings.in","http://gkonlineprojects.blogspot.in/p/blog-page.html","http://gkonlineprojects.blogspot.in/p/programming.html","http://gkonlineprojects.blogspot.in/p/sql-server.html")

    var slideshowspeed=2000

    var whichlink=0

    var whichimage=0

    function slideit()

    {

    if(!document.images)

    return 

    document.images.slide.src=slideimages[whichimage].src

    whichlink=whichimage

    if (whichimage<slideimages.length1)

    whichimage++

    else

    whichimage=0

    setTimeout("slideit()",slideshowspeed)

    }

    slideit()

    //-->

    </script>

    <p align="center">&nbsp;</p>

    </body>

    </html>

    Out Put:



    How t
    o send the Secret Key to Gmail using Asp.Net with C#.Net


    Code:

    protected void btnlogin_Click(object sender, EventArgs e)

        {

            if (txt_unam == null)

            {

                Label14.Text = "Enter the Username";

            }

            else if (txt_pass == null)

            {

                Label15.Text = "Enter the Password";

            }

            else

            {

                SqlConnection con = new SqlConnection("Data Source=gopikrishna;Initial Catalog=fuzzy;User ID=sa;Pwd=sa");

                con.Open();

                SqlCommand cmd = new SqlCommand("select email from registration where usernam = '" + txt_unam.Text + "'", con);

                emailid = cmd.ExecuteScalar().ToString();

                con.Close();


                Random rm = new Random();

                int rno = rm.Next(00000, 99999);

                string secki = rno.ToString();


                DataSet da = new DataSet();

                da = enobj.checkuser(txt_unam.Text, txt_pass.Text);

                if (da.Tables[0].Rows.Count > 0)

                {

                    if (da.Tables[0].Rows[0]["usernam"].ToString() == txt_unam.Text && da.Tables[0].Rows[0]["password"].ToString() == txt_pass.Text)

                    {

                        string gMailAccount = "user@gmail.com";

                        string password = "user";

                        string to;

                        string subject = "Secret Key for Downloading";

                        string message, emailid;

                        string secky;

                        fnam = Request.Params["id"];

                        con.Open();

                        SqlCommand cmm = new SqlCommand("update ownerfiles set secretkey = '" + secki + "' where filenam = '" + fnam + "'", con);

                        cmm.ExecuteNonQuery();

                        con.Close();


                        message = "<hr><br>" + "Secret Key:" + "<b>" + secki + "</b><br><br>";

                        to = emailid;

                        NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password);

                        MailMessage msg = new MailMessage();

                        msg.From = new MailAddress(gMailAccount);

                        msg.To.Add(new MailAddress(to));

                        msg.Subject = subject;

                        msg.Body = message;

                        msg.IsBodyHtml = true;


                        SmtpClient client = new SmtpClient("smtp.gmail.com");

                        client.EnableSsl = true;

                        client.UseDefaultCredentials = false;

                        client.Credentials = loginInfo;

                        client.Send(msg);


                        if (fnam == null)

                        {

                            Label13.Text = "Go to Home and type your Keyword";

                        }

                        else

                        {

                            Label9.Visible = false;

                            Label10.Visible = false;

                            txt_unam.Visible = false;

                            txt_pass.Visible = false;

                            btnlogin.Visible = false;


                            Label12.Visible = true;

                            txt_key.Visible = true;

                            btndwnld.Visible = true;

                        }


                    }

                    else

                    {

                        MsgBox.Show("Invalid User");

                    }

                }

                else

                {

                    MsgBox.Show("User does not exist");

                }

            }

        }

    Output:

    How to use Validation Controls in Asp.net


    Validation Controls are used for to check the webform.If the user provide the correct details or not.
    validations are 2 types
    1.Client-Side Validations
    2.Server-Side Validations

Client-side Validation using Javascript

Here we are using javascript for validating the form.

Server-Side Validations:

Serverside validations are different types

1.RequiredField Validator
2.RegularExpression Validator
3.Range Validator
4.Compare Validator





No comments:

Post a Comment