How to keep file in asyncupload during post back

2 posts, 0 answers
  1. Jerry
    Jerry avatar
    41 posts
    Member since:
    Mar 2012

    Posted 13 Feb Link to this post

    Hello,

    I have a user registration web form page where users have to enter specific fields. 

    I go through and fill out the info but when I leave a required field blank I have a server side error check.  When it does the error check I lose the document within my radAsyncUpload control.    The file is already saved in the App_Data till I save it when the post is error free.

     

    Can the control hold the file information till an error free post back is made?

    I don't want my users to have to select their file multiple times.

     

    Thank you,

    Jerry

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    830 posts

    Posted 17 Feb Link to this post

    Hello Jerry,

    The RadAsyncUpload has a mechanism for keeping the selected file across postbacks and it involves setting a the PostbackTriggers property. You can learn more about it in the following documentation article.
    You could use this functionality along with a HiddenField, the Value of which you can set to "valid" in the code behind and after the postback check the value and upload the file by clicking a hidden button. The selected file will be kept up to that point, because only a postback from Button1 will upload the files:
    <script type="text/javascript">
        function pageLoad() {
            var $ = $telerik.$;
            if ($("#HiddenField1").val() == "valid") {
                $("#HiddenField1").val("");
                $("#Button1").click();
            }
        }
    </script>
    <asp:HiddenField runat="server" ID="HiddenField1" />
    <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" TargetFolder="~/Uploads" PostbackTriggers="Button1">
    </telerik:RadAsyncUpload>
     
    <asp:Button Text="Upload" ID="Button2" runat="server" OnClick="Button2_Click" />
    <asp:Button runat="server" ID="Button1" Style="display: none;"></asp:Button>


    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top