ajaxfileupload页上的多个输入 [英] ajaxfileupload multiple inputs on page

查看:215
本文介绍了ajaxfileupload页上的多个输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ajaxFileUpload如下所述: HTTP://www.asp .NET / ajaxLibrary / AjaxControlToolkitSampleSite / AjaxFileUpload / AjaxFileUpload.aspx

I'm using ajaxFileUpload as described here: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AjaxFileUpload/AjaxFileUpload.aspx

除非我有相同的页面上有多个文件上传控件这是工作的罚款。具体来说,我想上传不同的文件不同的问题。当我上传的第一个页面上,它工作正常,但在一个页面上低了下去,只会上传的文件到答案的第一个问题。

It is working fine except when I have multiple file upload controls on the same page. Specifically, I am trying to upload different files for different questions. When I upload the first on the page, it works fine, but the one lower down on the page will only upload it's file into the answer for the first question.

我不敢肯定是有道理的......所以它可以帮助你知道,我的网页填充了动态使用ASCX文件的问题。文档ASCX文件看上去是这样的:

I'm not sure that makes sense... so it may help you to know that my page is populated with questions dynamically using ascx files. The document ascx file looks like this:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Document.ascx.cs" Inherits="ScholarshipApplication.controls.questions.Document" %>


<ajaxToolkit:AjaxFileUpload OnUploadComplete="UploadComplete"  ID="FileUploadControl" MaximumNumberOfFiles="1" runat="server" AllowedFileTypes="png,jpg,jpeg,pdf,tiff,tif,gif" />
<asp:LinkButton ID="downloadButton" runat="server" CausesValidation="false" OnClick="downloadButton_Click" />

和后面的代码:

public void UploadComplete(object sender, AjaxFileUploadEventArgs e)
        {
            entry.data = e.FileName;
            entry.setDocumentData(e.GetContents());

            this.downloadButton.Text = e.FileName;
        }



我最初的想法是,不知怎的,我需要帮助控件生成的JavaScript知道其中质疑应时触发。

My initial thoughts are that somehow I need to help the control's generated javascript to know which question it should be triggering when.

推荐答案

我相信这是在控件中的错误或这是由一些不常见的实现原因。其实,这种控制不支持在页面上的多个实例。考虑到使用 AsyncFileUpload控制代替或自定义的<$的一点源C $ C> AjaxFileUpload 控制。如果您更喜欢第二个选项,那么你需要从这里下载来源: http://ajaxcontroltoolkit.codeplex.com/SourceControl / BrowseLatest 并更改AjaxFileUpload.cs文件(这里是一个路径: /Server/AjaxControlToolkit/AjaxFileUpload/AjaxFileUpload.cs )。你需要做的是改变 ContextKey 常数属性​​相结合的控制的唯一ID的GUID背景下键:

I believe this is a bug in control or this was implemented by some non-obvious reason. Actually, this control doesn't support multiple instances on a page. Consider to use AsyncFileUpload control instead or customize a bit sources of the AjaxFileUpload control. If you prefer second option then you need to download sources from here: http://ajaxcontroltoolkit.codeplex.com/SourceControl/BrowseLatest and change AjaxFileUpload.cs file (here is a path: /Server/AjaxControlToolkit/AjaxFileUpload/AjaxFileUpload.cs). What you need to do is to change ContextKey constant to property for combining context key guid with unique id of control:

public class AjaxFileUpload : ScriptControlBase
{
    private const string ContextKeySuffix = "{DA8BEDC8-B952-4d5d-8CC2-59FE922E2923}";

    private string ContextKey
    {
        get { return this.UniqueID + "_" + ContextKeySuffix; }
    }



其实,如果你会看的的PreRender AjaxFileUpload 类的方法,你会很容易实现这种控制的这种行为振振有辞(第一个控制手柄上传所有同级页面控件)

Actually, if you'll look on PreRender method of AjaxFileUpload class you'll easy realize reson for such behavior of this control (the first control handle uploads from all sibling controls on a page).

这篇关于ajaxfileupload页上的多个输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆