This is a migrated thread and some comments may be shown as answers.

Launch Select Window on page load

1 Answer 200 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 03 Feb 2016, 09:40 PM

Hi guys,

I've been attempting to create and aspx page that will automatically launch the select window, as if the user had clicked the "Browse" button, as soon as the page loads.  I was able to launch the window successfully using a new button I created myself (ID "RunMe"), and as you can see I've tried a couple different methods in the code below to try and launch the window on page load (document.ready and an onload function call in the body tag).  I added in the timeouts in case the call was happening before the control finished loading.  I'm testing in Chrome Version 48.0.2564.97 m.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewFileUpload.aspx.cs" Inherits="CYBERWebPortal.NewFileUpload" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript">
        function OnClientFileUploaded(sender, args) {
            //var contentType = args.get_fileInfo().contentType;
            //alert(contentType); 
            
            __doPostBack('RadAsyncUpload1', '');
           
        }
        function OnClientClicking(sender) {
            setTimeout(function () {
                $telerik.$(".ruFileInput").click();
            }, 100);
            //$telerik.$(".ruFileInput").click();
        }
        function FinishedLoading(sender) {
            setTimeout(function () {
                $telerik.$(".ruFileInput").click();
            }, 900);
            //$telerik.$(".ruFileInput").click();
        }

        $(document).ready(function () {
            setTimeout(function () {
                document.getElementById("RunMe").click();
            }, 900);
        });

    </script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body onload="FinishedLoading()">
    <div>
        <button type="button" id="RunMe" onclick="OnClientClicking()">Test</button>
        <p><strong> Your test was successful. You have reached doc upload!</strong></p>
        
            
            <div style="display:inline-block;" > 
                <telerik:RadScriptManager runat="server" ID="RadScriptManager1" >
                <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
                </telerik:RadScriptManager>
                
        <telerik:RadAsyncUpload ID="RadAsyncUpload1" 
                runat="server"
                AutoAddFileInputs="false"
                OnFileUploaded="HandleFileUploaded" 
                OnLoad="HandlePageLoadForFiles" 
                OnClientFileUploaded="OnClientFileUploaded" 
                Localization-Select="Upload"  InputSize="25" 
                AllowedFileExtensions=".jpg,.jpeg,.pdf,.doc,.docx,.bmp,.tif,.tiff,.png,.txt,.ppt,.pptx,.xls,.xlsx,.rtf"
                TemporaryFolder="../App_Data/"
                TargetFolder="../TargetUploads/" 
                EnablePermissionsCheck="false"
                EnableInlineProgress="false" > 
        </telerik:RadAsyncUpload>
        
</div>
        
</div>

</body>
</html>

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 08 Feb 2016, 09:11 AM
Hello David,

Opening the Select dialog window when the page loads without any user interaction, clicking a button for example, would not work in all browsers due to security reasons. We have a forum thread, in which you can find more information about this behavior.

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
Tags
AsyncUpload
Asked by
David
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or