Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Commented Unassigned: AsyncFileUploadID=AsyncFileUpload1&rnd= [27593]

$
0
0

STEPS TO REPRODUCE ERROR

STEP 1

Configure AsyncFileUpload with normal client (JavaScript) and server methods.

__On client functions__:

uploadError(sender, args) {..} and function uploadComplete(sender, args) {..}

_On server codebehind_:

AsyncFileUpload1_UploadedComplete(..) and AsyncFileUpload1_UploadedFileError(..)

On ASPX add a button than only do a Postback.

Now upload a large file (over 4 mbytes the default limit). After detected uploadError on Client JavaScript Function, the control display on red background color the name of the file.

STEP 2

Click on the Button to generate a Postback.

RESULT:

Automatically launch a new browser tab showing a URL querystring like this:

http://localhost/ImagesInGridViewDb/tImageUpload1.aspx___?AsyncFileUploadID=AsyncFileUpload1&rnd=0008577673175017342___

What is the mean of:

?AsyncFileUploadID=AsyncFileUpload1&rnd=0008577673175017342

[See the image](https://skydrive.live.com/redir?resid=F3D7A503C5A2E642!133&authkey=!AFD5WoeoR16nmUg&v=3&ithint=photo%2c.JPG)






Comments: Hi. Indeed, in __AsyncFileUpload.pre.js__ (AjaxControlToolkit source code), in _onload: function (e) {..} executes the following lines that create the URL to postback: ``` mainForm.action = url + 'AsyncFileUploadID=' + this.get_element().id + '&rnd=' + Math.random().toString().replace(/\./g, ""); mainForm.target = this._iframeName; ``` The following solution works in Firefox 25, Opera 11, Chrome 21 and perhaps in other versions of these browsers, but works in IE7: ``` <script type="text/javascript"> var displayElement; // Initializes global variables and session state. function pageLoad() { displayElement = $get("ResultId"); } function uploadError(sender, args) { var ArchivoNombre = args.get_fileName(); var MensajeError = args.get_errorMessage(); var Mensaje = "Archivo no cargado: " + ArchivoNombre + " / ERROR..." + MensajeError; //2013-12-18 clearContents("#D6D5D9"); //clearContents("White"); form1.action = "WebForm1.aspx"; form1.enctype = "multipart/form-data"; form1.target = ""; displayElement.innerHTML = Mensaje; } function uploadStarted(sender, args) { } function uploadComplete(sender, args) { } function clearContents(colorName) { var AsyncFileUpload = $get("<%=AsyncFileUpload1.ClientID%>"); var txts = AsyncFileUpload.getElementsByTagName("input"); for (var i = 0; i < txts.length; i++) { var elemento = txts[i]; if (elemento.type == "text") { elemento.value = ""; elemento.style.backgroundColor = colorName; elemento.style.borderStyle = "solid" elemento.style.borderColor = "#A7A6A8"; elemento.style.borderWidth = "1px"; elemento.readonly = "readonly"; //elemento.style.opacity = 0; } //cuando elemento.type = file, lo resetea if (elemento.type == "file") { elemento.value = ""; //elemento.style.opacity = 0; } } } </script> ``` See on function uploadError that I have reassigned some properties of the form1: action, enctype, target. And I called to function clearContents to reset the INPUTs elements in the AsyncFileUpload. The HTML of the WebForm1.aspx: ``` <form id="form1" runat="server"> <div> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="True"> </asp:ToolkitScriptManager> <asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" Width="350px" onclientuploadcomplete="uploadComplete" onclientuploaderror="uploadError" onclientuploadstarted="uploadStarted" onuploadedcomplete="AsyncFileUpload1_UploadedComplete" onuploadedfileerror="AsyncFileUpload1_UploadedFileError" UploaderStyle="Modern" /> <p> <span style="background-color:Aqua" id="ResultId"></span> </p> <asp:Button ID="Button1" runat="server" Text="Generate Postback" /> </div> </form> ``` In codebehind only define the methods for the test: ``` protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { string x = ""; } protected void AsyncFileUpload1_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { string x = ""; } ``` I would like you to try this code or suggest a better solution for this problem. I also hope some solution for IE7 option.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>