//GLOAL為自定義APPCODE類
查找PAGE的CONTROL
HtmlForm form = (HtmlForm)this.Master.FindControl("form1");
ContentPlaceHolder CP = (ContentPlaceHolder)form.FindControl("ContentPlaceHolder1");
for (int i = 0; i < 4; i++)
{
string CName = "_fuFile" + Convert.ToString(i + 1);
FileUpload FU = (FileUpload)CP.FindControl(CName);
if (FU.HasFile)
{
string FName = FU.FileName;
FU.PostedFile.SaveAs(Server.MapPath(Global.ApplicationPath + "/onlineprint_upload" + "/" + DateTime.Now.ToString("yyyyMMdd") + "/" + userid + "/" + FName));
}
}
查找用戶控件中的CONTROL 直接用THIS.FINDCONTROL
查找REPEATER中的,要對應ITEM[I].findcontrol
查找GRIDVIEW 要對應ROW[I].CELL[I].CONTROL[I];
另外 創建文件夾和保存文件
string userid = Convert.ToString(Session["ComUserId"]);
string dir = Server.MapPath(Global.ApplicationPath + "/onlineprint_upload" + "/" + DateTime.Now.ToString("yyyyMMdd") + "/" + userid);
&
nbsp; System.IO.Directory.CreateDirectory(dir);
HtmlForm form = (HtmlForm)this.Master.FindControl("form1");
ContentPlaceHolder CP = (ContentPlaceHolder)form.FindControl("ContentPlaceHolder1");
for (int i = 0; i < 4; i++)
{
string CName = "_fuFile" + Convert.ToString(i + 1);
FileUpload FU = (FileUpload)CP.FindControl(CName);
if (FU.HasFile)
{
string FName = FU.FileName;
FU.PostedFile.SaveAs(Server.MapPath(Global.ApplicationPath + "/onlineprint_upload" + "/" + DateTime.Now.ToString("yyyyMMdd") + "/" + userid + "/" + FName));
}
}