documents.ascx.cs

来自「this is code for all person who want ro 」· CS 代码 · 共 50 行

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

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

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.ContentLength > 0)
            if (FileUpload2.PostedFile != null && FileUpload2.PostedFile.ContentLength > 0)
        {
            string fn1,fn2, loc;
            fn1=fn2 = loc = "";
            fn1 = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
            loc = Server.MapPath("~/doc");
            FileUpload1.PostedFile.SaveAs(loc + "/" + fn1);
            fn2 = loc = "";
            fn2 = System.IO.Path.GetFileName(FileUpload2.PostedFile.FileName);
            loc = Server.MapPath("~/doc_img");
            FileUpload2.PostedFile.SaveAs(loc + "/" + fn2);
            SqlDataSource1.InsertParameters[0].DefaultValue = txtname.Text;
            SqlDataSource1.InsertParameters[1].DefaultValue = txtdate.Text;
            SqlDataSource1.InsertParameters[2].DefaultValue = fn1;
            SqlDataSource1.InsertParameters[3].DefaultValue = txtdetails.Text;
            SqlDataSource1.InsertParameters[4].DefaultValue = fn2;
            SqlDataSource1.Insert();
            txtdate.Text = txtdetails.Text = txtname.Text = "";






        
        
        }
    }
}

⌨️ 快捷键说明

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