RadAsyncUpload

8 posts, 1 answers
  1. Jeremy
    Jeremy avatar
    6 posts
    Member since:
    Nov 2011

    Posted 20 Jun 2013 Link to this post

    I want the FileUploaded button to enable a submit button on the page. What's the most simple way of doing this?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Jun 2013 Link to this post

    Hi,

    I suppose you need to enable a button while selecting a file using RadAsyncUpload.
    JS:
    function OnClientFileUploaded(sender, args)
    {
        var btn = document.getElementById("button1");
        btn.disabled = false;
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeremy
    Jeremy avatar
    6 posts
    Member since:
    Nov 2011

    Posted 20 Jun 2013 Link to this post

    It's saying that btn is null and it cannot set the disabled property of a null of a null object.
  5. Jeremy
    Jeremy avatar
    6 posts
    Member since:
    Nov 2011

    Posted 20 Jun 2013 Link to this post

    <telerik:RadAsyncUpload ID="radaUploadDoc" runat="server" MaxFileInputsCount="1" ChunkSize="3000" PostbackTriggers="btnUpload" Enabled="False" OnFileUploaded="radaUploadDoc_FileUploaded" OnClientFileUploaded="OnClientFileUploaded">
        <FileFilters>
            <telerik:FileFilter Description="PDF(pdf)" Extensions="pdf" />
        </FileFilters>
    </telerik:RadAsyncUpload>
    <br />
    <asp:Button ID="btnUpload" runat="server" Text="Upload!" OnClick="btnUpload_Click" Enabled="False" />
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script>
            function OnClientFileUploaded(sender, args) {
                var btn = document.getElementById("btnUpload");
                btn.disabled = false;
            }
        </script>
    </telerik:RadScriptBlock>
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Jun 2013 Link to this post

    Hi,

    Here is the sample code I tried and it worked as expected at my end.
    <telerik:RadAsyncUpload ID="radaUploadDoc" runat="server" MaxFileInputsCount="1" ChunkSize="3000" PostbackTriggers="btnUpload" OnClientFileUploaded="OnClientFileUploaded">
       <FileFilters>
            <telerik:FileFilter Description="PDF(pdf)" Extensions="pdf" />
       </FileFilters>
    </telerik:RadAsyncUpload>
     <br />
    <asp:Button ID="btnUpload" runat="server" Text="Upload!" Enabled="False" onclick="btnUpload_Click"/>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
     <script type="text/javascript">
     function OnClientFileUploaded(sender, args) {
       var btn = document.getElementById("btnUpload");
       btn.disabled = false;
      }
    </script>
    </telerik:RadScriptBlock>

    Note: OnClientFileUploaded will fire only when RadAsyncUpload is Enabled. You are setting RadAsyncUpload as disabled in your code.

    Thanks,
    Shinu.
  7. Jeremy
    Jeremy avatar
    6 posts
    Member since:
    Nov 2011

    Posted 02 Jul 2013 Link to this post

    RadAsyncUpload is enabled after a postback checking the value of another field. When it posts back, it is then enabled. At that point, I then want the RadAsyncUpload to enable the button.
  8. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2013 Link to this post

    Hi Jeremy,

    I guess your requirement is like Initially the RadAsyncUpload is disabled and later it is enabled on a PostBack. Then after selecting some files to upload, the Upload button is enabled and finally clicking the upload button to upload files to server, the page Submit button is enabled. Please check the following code.

    ASPX:
    <asp:CheckBox ID="CheckBox1" runat="server" Text="Enable Upload" AutoPostBack="true"
        OnCheckedChanged="CheckBox1_CheckedChanged" />
    <br />
    <telerik:RadAsyncUpload ID="radaUploadDoc" runat="server" MaxFileInputsCount="1"
        Enabled="false" ChunkSize="3000" PostbackTriggers="btnUpload" OnFileUploaded="radaUploadDoc_FileUploaded"
        OnClientFileUploaded="OnClientFileUploaded">
        <FileFilters>
            <telerik:FileFilter Description="PDF(pdf)" Extensions="pdf" />
        </FileFilters>
    </telerik:RadAsyncUpload>
    <br />
    <asp:Button ID="btnUpload" runat="server" Text="Upload!" OnClick="btnUpload_Click"
        Enabled="False" />
    <asp:Button ID="btnSubmit" runat="server" Text="Sunmit Page" Enabled="false" />

    C#:
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (CheckBox1.Checked == true)
        {
            radaUploadDoc.Enabled = true;
        }
        else
        {
            radaUploadDoc.Enabled = false;
        }
    }
     
    protected void radaUploadDoc_FileUploaded(object sender, FileUploadedEventArgs e)
    {
     //your code to upload files
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        btnSubmit.Enabled = true;
    }

    JavaScript:
    <script type="text/javascript">
        function OnClientFileUploaded(sender, args) {
            var btn = document.getElementById("btnUpload");
            btn.disabled = false;
        }
    </script>

    Thanks,
    Shinu.
  9. Jeremy
    Jeremy avatar
    6 posts
    Member since:
    Nov 2011

    Posted 08 Jul 2013 Link to this post

    I can tell how little I code web forms.

    getElementById('<%=btnUpload.ClientID %>');


    All fixed and working. 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017