⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reg.aspx.cs

📁 通过微软的最新技术ASP.NET2.0开发一个类似BtoC、CtoC的企业产品信息发布系统。 整体设计思想与规划: 用Firework设计图形
💻 CS
字号:
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 System.Data.OleDb;
using System.Collections;

public partial class Reg : System.Web.UI.Page
{
    //重新简单总结了一下ASP.NET1.1所有的简单的web服务器表单控件,验证控件!附加注册图片验证码~
    protected void Page_Load(object sender, EventArgs e)
    {
      
        this.Panel2.Visible = false;
        this.Button3.Attributes.Add("onclick", "window.close()");
        ArrayList values = new ArrayList();
        values.Add("1--10万");
        values.Add("10万以下");
        values.Add("100万以上");
        this.DropDownList1.DataSource = values;
        this.DropDownList1.DataBind();
        ListBox1.Items.Add(new ListItem("10人以下","10人以下"));
        ListBox1.Items.Add(new ListItem("10--100人","10--100人"));
        ListBox1.Items.Add(new ListItem("100人以上","100人以上"));
        //晕死,忘记做个二级分类注册的,以下是二级分类的撒!
        if (!IsPostBack)
        {  this.Panel1.Visible = false;
            string que = "select * from Catalogs";

            this.DropDownList2.DataTextField = "CatalogName";

            this.DropDownList2.DataValueField = "Catalogid";

            this.DropDownList2.DataSource = db.ds(que);

            this.DropDownList2.DataBind();
        }


        
    }
    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        string strNum = Session["Num"].ToString();
        if (yz.Text == strNum)
            args.IsValid = true;
        else
            args.IsValid = false;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
            string fullfilename = this.File1.PostedFile.FileName;
            string filename = fullfilename.Substring(fullfilename.LastIndexOf("\\") + 1);
            string type = fullfilename.Substring(fullfilename.LastIndexOf(".") + 1);
            if (type == "jpg" || type == "bmp" || type == "gif")
            {
                this.File1.PostedFile.SaveAs(Server.MapPath("up") + "\\" + filename);
                this.Image1.ImageUrl = "up/" + filename;
            }
            else
            {
                Response.Write("<script>alert('您选择的文件格式有错!')</script>");
            }  

     }
    protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
    {
        string cid = args.Value;
        int count = Convert.ToInt32(db.scr("select count(*) from Cs where c1='" + cid + "'"));
        if (count > 0)
        {
            args.IsValid = false;
        }
        else
        {
            args.IsValid = true;
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {

            db p = new db();

 

            p.c1 = Server.HtmlEncode(this.TextBox1.Text.ToString().Replace("'", "!"));
            p.c2 = Server.HtmlEncode(this.TextBox2.Text);
            p.c3 = Server.HtmlEncode(this.TextBox3.Text);
            p.c4 = Server.HtmlEncode(this.TextBox5.Text);
            p.c5 = this.Image1.ImageUrl;
            p.c6 = Server.HtmlEncode(this.TextBox6.Text);
            if (this.RadioButton1.Checked)
            {
                p.c7 = this.RadioButton1.Text;
            }
            else
            {
                p.c7 = this.RadioButton2.Text;
            }
            p.c8 = Server.HtmlEncode(this.TextBox7.Text);
            p.c9 = this.RadioButtonList1.SelectedValue.ToString();
            p.c10 = this.CheckBox4.Text;
            for (int i = 0; i < this.CheckBoxList1.Items.Count; i++)
            {
                if (this.CheckBoxList1.Items[i].Selected)
                {
                    p.c11 =p.c11+this.CheckBoxList1.Items[i].Text.ToString();
                    p.c11 = p.c11 + "<br>";
                }
            }
            p.c12 = this.ListBox1.SelectedValue.ToString();
            p.c13 = this.DropDownList1.SelectedValue.ToString();
            p.c14 = Server.HtmlEncode(this.TextBox8.Text);
            string que = "insert into Cs(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,SubCatalogid)values('" + p.c1 + "','" + p.c2 + "','" + p.c3 + "','" + p.c4 + "','" + p.c5 + "','" + p.c6 + "','" + p.c7 + "','" + p.c8 + "','" + p.c9 + "','" + p.c10 + "','" + p.c11 + "','" + p.c12 + "','" + p.c13 + "','" + p.c14 + "',"+this.DropDownList3.SelectedValue+")";
            if (db.insert(que))
            {

                    this.Panel1.Visible = false;
                    this.Panel2.Visible = true;
                    Session["c1"] = this.TextBox1.Text;
                    this.Label1.Text = "http://4ec.cn/Shop.aspx?shop=" + Session["c1"].ToString();
            }
        }
    }

    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        string que1 = "select * from SubCatalogs where Catalogid="+this.DropDownList2.SelectedValue;

        this.DropDownList3.DataTextField ="SubCatalogName";

        this.DropDownList3.DataValueField = "SubCatalogid";

        this.DropDownList3.DataSource = db.ds(que1);

        this.DropDownList3.DataBind();
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        this.Panel1.Visible = true;
        this.Panel3.Visible = false;
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -