post.aspx.cs

来自「通过微软的最新技术ASP.NET2.0开发一个类似BtoC、CtoC的企业产品信」· CS 代码 · 共 51 行

CS
51
字号
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;

public partial class Post : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Session["shop"] == null)
            Response.Redirect("Default.aspx");
    }
    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 Button2_Click(object sender, EventArgs e)
    {
        string shop = Request.QueryString["shop"];
        string p1 = Server.HtmlEncode(this.TextBox5.Text);
        string p2 = this.Image1.ImageUrl;
        string p3 = Server.HtmlEncode(this.DXTB1.Text);
        string que = "insert into Ps(p1,p2,p3,c1)values('" + p1 + "','" + p3 + "','" + p2 + "','" + shop + "')";
        if(db.insert(que))
            Response.Write("<script>alert('您已经成功发布新产品!');</script>");
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Write("<script>history.go(-2);</script>");
    }
}

⌨️ 快捷键说明

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