This is a migrated thread and some comments may be shown as answers.
RadAsyncUpload
7 Answers 64 Views
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 20 Jun 2013, 01:45 PM
I want the FileUploaded button to enable a submit button on the page. What's the most simple way of doing this?

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 20 Jun 2013, 02:09 PM
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.
0
Jeremy
Top achievements
Rank 1
answered on 20 Jun 2013, 03:03 PM
It's saying that btn is null and it cannot set the disabled property of a null of a null object.
0
Jeremy
Top achievements
Rank 1
answered on 20 Jun 2013, 03:09 PM
<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>
0
Shinu
Top achievements
Rank 1
answered on 21 Jun 2013, 04:23 AM
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.
0
Jeremy
Top achievements
Rank 1
answered on 02 Jul 2013, 06:55 PM
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.
0
Accepted
Shinu
Top achievements
Rank 1
answered on 04 Jul 2013, 05:31 AM
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.
0
Jeremy
Top achievements
Rank 1
answered on 08 Jul 2013, 09:09 PM
I can tell how little I code web forms.

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


All fixed and working. 
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Jeremy
Top achievements
Rank 1
Share this question
or