SharePoint/Additional fields scenario

5 posts, 0 answers
  1. Larkin
    Larkin avatar
    11 posts
    Member since:
    Nov 2011

    Posted 28 Nov 2011 Link to this post

    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
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 29 Nov 2011 Link to this post

    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
  3. Larkin
    Larkin avatar
    11 posts
    Member since:
    Nov 2011

    Posted 30 Nov 2011 Link to this post

    Thanks so much for your help--this is exactly what I needed!

    Kind regards,
    Larkin
  4. Larkin
    Larkin avatar
    11 posts
    Member since:
    Nov 2011

    Posted 08 Dec 2011 Link to this post

    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
  5. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 09 Dec 2011 Link to this post

    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
Back to Top