//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);
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));
}
}
HtmlForm form = (HtmlForm)this.Master.FindControl("form1");
ContentPlaceHolder CP = (ContentPlaceHolder)form.FindControl("ContentPlaceHolder1");
UserControl Rent_Info = (UserControl)CP.FindControl("Rent_Info1");
Label _lb = (Label)Rent_Info.FindControl("_lbDistrict");
_lbTitle.Text = _lb.Text;