This is a migrated thread and some comments may be shown as answers.

SharePoint/Additional fields scenario

4 Answers 46 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Larkin
Top achievements
Rank 1
Larkin asked on 28 Nov 2011, 09:41 PM
I am wondering if the following scenario is supported:

  • After each file is uploaded to the temp folder, prompt the user to enter additional info about the file (I can see how to do this from the posted demo)
  • Persist the additional fields and file info until a specific button triggers a postback (I posted another thread asking how to use a PostbackTrigger when the triggering control is in a different user control)
  • In the OnFileUploaded server-side event handler, prevent the file from being auto-saved to TargetFolder, and instead save the uploaded file to a SharePoint document library along with the metadata provided in the "additional fields" on the client

To explain further, the reason I don't want the RadAsyncUpload control to use the default auto-save functionality using the TargetFolder is that the location the file will be saved to is determined based on some metadata about the file and some other business rules. In other words, I need to access data in the "additional fields" for each file in the server-side OnFileUploaded event handler and then determine the appropriate location to save the file (within a SharePoint document library).

Thanks, your help is greatly appreciated.

Kind regards,
Larkin

4 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 29 Nov 2011, 04:08 PM
Hello Larkin,

The scenario that you describe in the first three sections of your post is quite interesting but is not supported out of the box. However we can provide you a script that implements this behaviour.

Additionally - you can try uploading documents in SharePoint 2010 Document Library programmatically with RadAsyncUpload simply by opening the library and adding the files in this way:
protected void Button1_Click(object sender, System.EventArgs e)
{
    using (var site = new SPSite("http://localhost"))
    {
        using (SPWeb web = site.OpenWeb())
        {
            SPDocumentLibrary docs = (SPDocumentLibrary)web.Lists["MyLibrary"];
            SPFileCollection files = docs.RootFolder.Files;
                     
            foreach (UploadedFile file in RadAsyncUpload1.UploadedFiles)
            {
                if(!CheckFileExists(file.FileName, files))
                {
                    var value = file.GetFieldValue("TextBox");
                    using (Stream fs = file.InputStream)
                    {
                        docs.RootFolder.Files.Add(file.GetName(), fs, true);
                    }
                }
            }
 
        }
    }
}

I prepared you an implementation of the script I mentioned above within a runnable WebPart – please find it attached.

Regards,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Larkin
Top achievements
Rank 1
answered on 30 Nov 2011, 09:09 AM
Thanks so much for your help--this is exactly what I needed!

Kind regards,
Larkin
0
Larkin
Top achievements
Rank 1
answered on 08 Dec 2011, 07:28 AM
By the way, what is the following code doing?

$ = $telerik.$;

Will this cause a conflict with the jQuery scripts that I already have defined in the page?

Thanks,
Larkin
0
Kalina
Telerik team
answered on 09 Dec 2011, 05:52 PM
Hello Larkin,

JQuery is included in our controls and the jQuery object is available as "$telerik.$".
"var $ = $telerik.$;" simply gets a reference to this object in order to use it later in code.

Greetings,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
AsyncUpload
Asked by
Larkin
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Larkin
Top achievements
Rank 1
Share this question
or