【问题标题】:file upload fields get the empty value文件上传字段获取空值
【发布时间】:2013-09-28 12:50:12
【问题描述】:

这是我的问题。我正在动态添加文件上传字段并将每个文件上传字段添加到集合中,就像这样

static List<FileUploadField> fuploadcollection = new List<FileUploadField>();

,到目前为止一切顺利。但是当我尝试在文件上传字段中上传图像时,我得到了空的文件上传字段。但是当我通过断点观看它时,它似乎填充了“fuploadcollection”集合。

这是我的代码;

添加文件上传功能;

    public partial class UserControl1 : System.Web.UI.UserControl
    {
        static int? _currentflag = 0;

        static List<FileUploadField> fuploadcollection = new List<FileUploadField>();

........
........
.........
       protected void addImages_Click(object sender, DirectEventArgs e)
            {
                int? nn = null;

                X.Msg.Alert("hello", "hello").Show();
                _currentflag = (!string.IsNullOrEmpty(txtcurrentflag.Text)) ? Convert.ToInt32(txtcurrentflag.Text) : nn;
                FileUploadField fileUploadField = new FileUploadField()

                {
                    ID = "FileUploadField" + _currentflag,
                    Width = 280,
                    Icon = Icon.Add,
                    ClientIDMode = ClientIDMode.Static,
                    Text = "Göz at",
                    FieldLabel = "Resim-" + _currentflag,
                    Flex = 1,
                    ButtonText="resim seç"

                };

                fileUploadField.AddTo(this.pnlResim, true);
                if (string.IsNullOrEmpty(txtcurrentflag.Text) || txtcurrentflag.Text == "0")
                {
                    fuploadcollection.Clear();
                }
                fuploadcollection.Add(fileUploadField);

                _currentflag++;
                txtcurrentflag.Text = _currentflag.ToString();


            }

这是给出错误的这部分(无法输入if语句) * 但似乎 fuploadcollection 已满(例如,它的计数显示超过 1)

            foreach (var item in fuploadcollection)
                {
                    if (item.HasFile)
                    {
                        string resimadi = UploadImage.UploadImages(item);

【问题讨论】:

  • 你得到了什么异常?
  • 没有例外,只是文件上传字段为空
  • 你给 txtcurrentflag 文本框的值是多少?
  • 当点击添加按钮时,它会增加数字 1,并以 1 开头,然后在点击添加按钮时增加

标签: c# asp.net file-upload ext.net


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2018-07-27
    • 2011-03-17
    • 2015-07-28
    • 2017-08-01
    • 1970-01-01
    • 2013-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多