.net中的FINDCONTROL和创建文件夹,保存文件
2007-11-07 01:18
127 查看
//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;
查找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;
相关文章推荐
- 创建文件夹,并且保存文件
- 保存一个文件并创建对应的目录文件夹
- 练习文件保存按照日期来创建文件夹,并保存
- .NET按照创建时间获取文件夹文件
- android打开文件、保存对话框、创建新文件夹对话框(转载)
- IOS在Document目录下创建文件夹、保存、读取、以及删除文件
- C语言 创建一个 txt 文件 bin输入字符 保存文件在工作文件夹里
- yii2 createDirectory 文件上传的保存文件和递归创建文件夹
- mfc 创建文件夹并将文件保存路径设置为新建文件夹内
- Android sd卡创建文件夹保存文件
- 补 上一个 spark导出hbase表信息的工具类(获取文件夹文件信息、删除文件夹、保存文件)
- python文件夹遍历,文件操作,获取文件修改创建时间
- java创建文件以及文件夹
- 在.NET中快速创建一个5GB、10GB或更大的空文件
- 判断文件文件夹存在与否 创建文件夹
- cmd命令创建文件文件夹
- winform 中 将listview数据 以excel格式导出 保存在可选择的文件夹下 但文件打开的时候有问题
- Android中创建文件夹和文件的操作
- 自动从网站上面下载文件 .NET把网站图片保存到本地
- ubuntu创建、删除文件及文件夹,强制清空回收站方法