京东网项目的所得

来源:互联网 发布:mac appstore下载失败 编辑:程序博客网 时间:2024/05/16 06:50
 

上一周是我们的第一次项目周,虽然这次我们组完成的不是很好,但是我对这一次的项目周还是充满期待的,毕竟这是自己第一次的做项目,我也很想看看自己究竟能做的怎么样,自己在这段时间里究竟学的怎么样,所以我还是满怀期待的,但是最后的结果还是令我很是失望。不过,通过这次的失败,我也明白了其实这次的失败我们学的不怎么样有一定的因素,但是我认为这并不是我们组取得这个结局的主导因素,我认为主导因素还是我们组的每个人之间的不够配合,所以这一次我并不气馁,我相信先一次的项目我们组会比这一次做得更好。

通过这次的项目实践,我学到了很多在课堂内容中所不能学到的东西,例如:

1.通过这次项目,我学会了怎么样在注册和找回密码时,向注册人和要找回密码的人发送邮件信息来通知人家;

注册发邮件:(网易邮箱)
string strSmtpServer = "smtp.163.com";
        string strFrom = "你的邮箱号";
        string strFromPass = "你的邮箱密码";
        string strto = this.txtEmail.Text;(输入邮箱的文本框)
        string strSubject = "所发邮箱内容的主题";
        string strBody = "恭喜您账号密码修改成功,账号:'" +

this.username.Text + "新密码:123456"  + "'";(邮箱的正文内容)
        System.Net.Mail.SmtpClient client = new SmtpClient

(strSmtpServer);
        client.UseDefaultCredentials = true;
        client.Credentials = new System.Net.NetworkCredential

(strFrom, strFromPass);
        client.DeliveryMethod = SmtpDeliveryMethod.Network;

        System.Net.Mail.MailMessage message = new MailMessage

(strFrom, strto, strSubject, strBody);
        message.BodyEncoding = System.Text.Encoding.UTF8;
        message.IsBodyHtml = true;
        client.Send(message);

2.通过这次项目,我还学会了怎么获取焦点;

<script type="text/javascript">
        function text() {
            var as = document.getElementById("TextBox1");
            as.focus();
        }
    </script>
</head>
<body onload="text()">
    <form id="form1" runat="server">
    <div>
   
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server"

onclick="Button1_Click" Text="Button" />
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
   
    </div>
    </form>
</body>

3.在做京东网这个项目中,我也学会了如何在注册时添加验证码

 

 

第一步:添加一个页面,页面代码如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckCode.aspx.cs" Inherits="CheckCode" %>

 

<!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 runat="server">

    <title>无标题页</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

   

    </div>

    </form>

</body>

</html>

第二步:添加页面的cs代码:

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using System.Drawing;

//这是一个生成验证码的网页

public partial class CheckCode : System.Web.UI.Page

{

    private string GenerateCheckCode()

    {

        int num;

        char code;

        string checkCode = string.Empty;

        Random random = new Random();

        for (int i = 0; i < 6; i++)//循环次数决定验证码的位数

        {

            num = random.Next();

            if (num % 2 == 0)

            {

                code = (char)('0' + (char)(num % 10));

            }

            else

            {

                code = (char)('A' + (char)(num % 26));

            }

 

            checkCode += code.ToString();

        }

        Response.Cookies.Add(new HttpCookie("CheckCode", checkCode));

        return checkCode;

    }

 

 

    protected void Page_Load(object sender, EventArgs e)

    {

        CreateCheckCodeImg(GenerateCheckCode());

    }

 

    private void CreateCheckCodeImg(string checkCode)

    {

        if (checkCode == null || checkCode.Trim() == String.Empty)

            return;

        Bitmap img = new Bitmap((int)Math.Ceiling((checkCode.Length * 12.5)), 22);

       

        Graphics g = Graphics.FromImage(img);

        try

        {

            Random random = new Random();

            g.Clear(Color.White);

 

 

            //画图片的背景线

            for (int i = 0; i < 2; i++)

            {

                int x1 = random.Next(img.Width);

                int x2 = random.Next(img.Width);

                int y1 = random.Next(img.Width);

                int y2 = random.Next(img.Width);

                g.DrawLine(new Pen(Color.Black), x1, y1, x2, y2);

            }

 

            //画出指定的字符

            Font font = new Font("Arial", 12, (FontStyle.Bold));

            System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Blue, Color.Red, 1.2f, true);

            g.DrawString(checkCode, font, brush, 2, 2);

 

            //画图片的前景噪点

            for (int i = 0; i < 100; i++)

            {

                int x = random.Next(img.Width);

                int y = random.Next(img.Height);

                img.SetPixel(x, y, Color.FromArgb(random.Next()));

            }

            g.DrawRectangle(new Pen(Color.Silver),0,0,img.Width-1,img.Height-1);

            System.IO.MemoryStream ms=new System.IO.MemoryStream();

            img.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);

            Response.ClearContent();

            Response.ContentType="image/Gif";

            Response.BinaryWrite(ms.ToArray());

       

        }  

        finally

        {

            g.Dispose();

            img.Dispose();

        }

    }

 

}

 

 

第三步:在需要验证码的网页引用产生验证码的网页:

在你需要调用验证码的网页中添加一个<img>标签,将img标签的src设置成刚刚新添加的那个aspx!比如<img alt="验证码" src="CkeckCode.aspx"></img>

下面是刷新功能:

你可以把img标签和一个linkbutton一起加入到updatepanel中,然后生成一个linkbutton的click事件,不用在里面写任何代码的,就可以达到刷新验证码的效果了.

 

 

最后一步:验证验证码:

在验证页面里添加以下代码:

 HttpCookie cookie = Request.Cookies["CheckCode"];

       

            if (cookie.Value == tbYanZM.Text)

            {

                Response.Write("...验证码正确");

 

            }

4.经过这一周的做项目我学会了怎么编写双重导航菜单(通过js实现的)

把如下代码加入<body>区域中
<FORM name=doublecombo>
<P align=center><SELECT name=example 
onchange=redirect(this.options.selectedIndex) size=1> <OPTION 
  selected>」JavaScript2000」</OPTION> <OPTION>」动画图库」</OPTION> 
  <OPTION>」风景区」</OPTION></SELECT> <SELECT name=stage2 size=1> <OPTION selected 
  value=allspcer.htm>」Java Script</OPTION> <OPTION 
  value=../javaapplet/index.htm>」Java Applet</OPTION> <OPTION 
  value=../cgi/index.htm>」C G I</OPTION> <OPTION 
  value=../explain/route.htm>」CGI相关设定</OPTION> <OPTION 
  value=../free.htm>」免费资源</OPTION> <OPTION value=../hotel.htm>」饭店资料</OPTION> 
  <OPTION value=mailto:webmaster@javascript2000.com>」E-Mail</OPTION></SELECT> <INPUT name=test onclick=go() type=button value=Go!>
<SCRIPT language=JavaScript>
<!--  
var groups=document.doublecombo.example.options.length  
var group=new Array(groups)  
for (i=0; i<groups; i++)  
group[i]=new Array()  
group[0][0]=new Option("」Java Script","allspcer.htm")  
group[0][1]=new Option("」Java Applet","../javaapplet/index.htm")  
group[0][2]=new Option("」C G I","../cgi/index.htm")  
group[0][3]=new Option("」CGI相关设定","../explain/route.htm")  
group[0][4]=new Option("」免费资源","http://www.qpsh.com")  
group[0][5]=new Option("」饭店资料","../hotel.htm")  
group[0][6]=new Option("」E-Mail","mailto:webmaster@javascript2000.com")  
group[1][0]=new Option("」分隔线","../pictures/bar/1.htm")  
group[1][1]=new Option("」施工中","../pictures/work/1.htm")  
group[1][2]=new Option("」HOT","../pictures/hot/1.htm")  
group[1][3]=new Option("」邮件", "../pictures/email/1.htm")  
group[1][4]=new Option("」插图", "../pictures/new/1.htm")  
group[1][5]=new Option("」插画商标", "../pictures/icon/1.htm")  
group[1][6]=new Option("」方向指标", "../pictures/arow/1.htm")  
group[1][7]=new Option("」首页图片", "../pictures/home/1.htm")  
group[1][8]=new Option("」前面标题", "../pictures/start/1.htm")  
group[1][9]=new Option("」卡通人物", "../pictures/cartoon/1.htm")  
group[1][10]=new Option("」欢迎光临", "../pictures/welcome/1.htm")  
group[1][11]=new Option("」动物", "../pictures/animal/1.htm")  
group[2][0]=new Option("」天后宫","../island/temple.htm")  
group[2][1]=new Option("」天安门","../island/battery.htm")  
group[2][2]=new Option("」天坛","../island/lighthouse.htm")  
group[2][3]=new Option("」北海公园","../island/seapark.htm")  
var temp=document.doublecombo.stage2  
function redirect(x){  
for (m=temp.options.length-1;m>0;m--)  
temp.options[m]=null  
for (i=0;i<group[x].length;i++){  
temp.options[i]=new Option(group[x][i].text,group[x][i].value)  
 
temp.options[0].selected=true  
 
function go(){  
location=temp.options[temp.selectedIndex].value  
 
//-->  
</SCRIPT></FORM>

在刚开始的时候我就提到了失败是我们自身的实力不如别人好,但是我却并不认为这是我们失败的主要原因,由于彼此之间从来没有这么配合过使我们都不知道该从何下手,所以我认为这是最为重要的失败原因。如果一个团队没有一个好的领导者,彼此之间都是不会配合的,那么就算这个团队每个人的实力都很强,我想它也不会是一个星光灼灼的耀眼的金星。我很期待我们组在下一次的项目中,每个组员之间的配合能够取得很大的进步,只有这样我们才会做到最好。
原创粉丝点击