none
custom list new application page with ListFieldIterator and SaveButton

    General discussion

  • i got a requirement to upload a file onto SharePoint while keeping user defined file metadata in a seperate list (similar, but not the same as out of box list attachment or document library).

    I can add a html file input control onto the custom metadata list new form page, but to save the file to user specified location, i need to write server side code. I can write a file upload web part, but the web part cannot get the value of file destination url specified on the list form. A workaround is to add an itemadded event receiver for the custom metadata list, in the event receiver, get the file with httpcontext.current.request.files and save it to its destination.

    However, i really does not like the idea of seperate the logic in two places: html input control in web part and save in event receiver. It will be great if i can customize the custom list new form with server side code. I tried putting DataFormWebPart onto a custom application page, it display well, after i click save, it return to the list view page, but new item is not created and saved.

    Finally, it seems that ListFieldIterator and SaveButton works on a custom application page. what follows is part of the code:

    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
        <SharePoint:ListFieldIterator ID="TestListFieldIterator" runat="server" ControlMode="New" ListId="{44A7453E-0625-41FE-95AB-70ED059644B9}" />
        <SharePoint:SaveButton runat="server" ID="CustomFormSaveButton" Text="Create!" ControlMode="New" ListId="{44A7453E-0625-41FE-95AB-70ED059644B9}" />
    </asp:Content>
    I had not add the file upload onto this application page yet. But i guess it will work.


    Friday, September 27, 2013 7:28 AM

All replies

  • Hi,

    Why not use custom rendering template instead of application page? It's way less pain. All you need is to create custom rendering template for new form and instead of standar save button use derived one with your custom logic.

    Friday, September 27, 2013 10:02 AM
  • with an application page, i can write server side code, such as get the filestream of the uploaded file, and read the file content at server side, and store the file at custom location. Can i do this with custom rendering template?
    Tuesday, October 08, 2013 8:54 AM
  • If you can create custom save button implementation, I don't see why you couldn't do what you have described.

    We got couple customized save buttons to achieve things like custom redirect, related item creation and so on.

    Tuesday, October 08, 2013 9:13 AM