62,046
社区成员
发帖
与我相关
我的任务
分享
<asp:Panel ID="Panel1" runat="server" Width="100%">
<uc1:UpPic ID="UpPic1" runat="server"></uc1:UpPic>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" style="display:none" Width="100%">
<uc2:UpFile ID="UpFile1" runat="server" />
</asp:Panel>
//我页面上有两个Panel,分别用来做两部分文件的上传
//如果使用HttpFileCollection Request.Files的方法,获取的是页面上所有上传控件的值.
//因为我是动态添加的控件
//控件的id分别是mypic1,mypic2.....myfile1,myfile2....
//小弟不才,想请教各位关于怎样只获取一个panel里面的上传控件的值?
protected void AddPic_Click(object sender, EventArgs e)
{
HttpFileCollection hfc = Request.Files;
string f_Name, f_Size, f_Type, f_Extented, newFileName, f_Path;
for (int i = 0; i <= hfc.Count - 1; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.FileName != "")
{
f_Name = Path.GetFileName(hpf.FileName);
Response.Write(i+"、"+f_Name+"<br>");
}
}