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>