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

CrossPagePostBack fails if postback button initially disable.

3 Answers 40 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
K
Top achievements
Rank 1
K asked on 04 Jan 2011, 08:14 PM
Hello,

I've encountered an odd problem attempting to use the "PostBackUrl" property of the button used to send the postback which causes the uploader to save the file.

Everything works as planned as long as the button is initially enabled.  However, if the button starts out disabled then the cross page postback doesn't occur. 

This is hard for me to explain clearly so I'm including some code I was testing with.   There are two buttons on this page.  The only difference between the buttons, besides their ID, is that one button is initially disabled and the other one is enabled.  The file is uploaded when either button is clicked.  But only the button which is initally enabled sends a response to the second page.  

I did notice there was a query in the URL after testing with the disabled button:  test.aspx?RadUrid=4ec5a3c0-0503-422b-83d0-743982ca7ffa

I also tried, without luck,  the suggestion in this post ASyncUpload Issue? forum post since it was possible the problem was caused by the same factors.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<head runat="server">
    <title></title>
   
</head>
<body>  
  
    <form id="form1" runat="server">
        
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        //<![CDATA[
  
        function fileUploaded(sender, eventArgs) {
            var btn = $get("<%= Me.BTN_loadfile.ClientID%>");
            if (typeof (btn) != "defined") {
                btn.disabled = false;
            }
        }
  
        //]]>
    </script>
    </telerik:RadCodeBlock>
  
    <telerik:RadProgressManager ID="RPM_importAdmin" runat="server" />
        <br />
        File to load administrators from (.CSV,.XLS, or .XLSX):
        <br />
        <br />
        <telerik:RadAsyncUpload ID="RAU_uploadFile" MaxFileInputsCount="1" MaxFileSize="10485760" InputSize="60" AllowedFileExtensions="csv,xls,xlsx" runat="server" OverwriteExistingFiles="true" OnClientFileUploaded="fileUploaded" >
            <Localization Select="Browse" />
        </telerik:RadAsyncUpload>
        <br />
        <br />
        <telerik:RadProgressArea ID="RPA_uploadFile" DisplayCancelButton="true" runat="server">
        </telerik:RadProgressArea>
        <asp:Button ID="BTN_loadfile" runat="server" Text="Should Go" Enabled="false" CausesValidation="false" PostBackUrl="~/test2.aspx"></asp:Button>
        <asp:Button ID="Button1" runat="server" Text="Goes" CausesValidation="false" PostBackUrl="~/test2.aspx"></asp:Button>
    <br />
    </form>
</body>
</html>


The code-behind for the SECOND page is the following.   The code-behind for the first page just sets values for the TemporaryFolder and TargetFolder properties.

Imports System.IO
Imports Telerik.Web.UI
  
Partial Class test2
    Inherits System.Web.UI.Page
  
    Protected fileUploader As RadAsyncUpload = Nothing
  
    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        If PreviousPage Is Nothing Then
            If Not IsPostBack Then
                Me.Label1.Text = "no previous page"
            End If
        Else
            Me.fileUploader = CType(PreviousPage.Form.FindControl("RAU_uploadFile"), RadAsyncUpload)
            If Me.fileUploader IsNot Nothing AndAlso Me.fileUploader.UploadedFiles.Count > 0 Then
                Me.Label1.Text = "File: " & Path.Combine(Me.fileUploader.TargetFolder, Me.fileUploader.UploadedFiles(0).FileName)
            End If
        End If
    End Sub
  
End Class

The version of the Telerik .dll is: 2010.3.1215.35

Any help or ideas would be greatly appreciated.

Thanks,

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 07 Jan 2011, 01:32 PM
Hello K,

This is not a problem with RadAsyncUpload but with the way ASP.NET handles disabled buttons. In order to workaround the issue removed the Enabled="false" declaration from the button and, instead, disable it on the client using the following script:

Sys.Application.add_load(function() {
            $get("BTN_loadfile").disabled = "disabled";
        });


Best wishes,
Genady Sergeev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
K
Top achievements
Rank 1
answered on 07 Jan 2011, 02:43 PM
Thanks Genady,

I had to modify the code a bit, but it worked like a charm.   I used:

Sys.Application.add_load(function() {
            var btn = $get("<%=Me.BTN_loadfile.ClientID%>");
            if ((typeof (btn) != "defined") && (btn != null)) {
                btn.disabled = true;
            }
        });

Perhaps due to the use of masterpages or because the button is not initially visible?
0
Genady Sergeev
Telerik team
answered on 12 Jan 2011, 10:50 AM
Hello K,

To be honest I am not sure of the exact reason. I guess it has something to do with the button being disabled initially.

Best wishes,
Genady Sergeev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
AsyncUpload
Asked by
K
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
K
Top achievements
Rank 1
Share this question
or