AsyncUpload and multiple RadWindow

6 posts, 1 answers
  1. Gabriel
    Gabriel avatar
    3 posts
    Member since:
    Jul 2013

    Posted 11 Feb 2014 Link to this post

    I want to create a 2 pages/windows which:

    • The first page is used to upload a file and when I press next, goes to the second page
    • The second page I can enter some values based on the file uploaded

    I'm not sure how I can transition between the 2 pages without closing the first page and reopen the second page. Is there a way to do that?

    Thanks,

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Feb 2014 in reply to Gabriel Link to this post

    Hi Gabriel,

    Please have a look into the following code snippet to open a second RadWindow without closing the first RadWindow.

    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <Windows>
            <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true">
                <ContentTemplate>
                    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server">
                    </telerik:RadAsyncUpload>
                    <telerik:RadButton ID="RadButton1" runat="server" Text="Next Page" OnClick="RadButton1_Click">
                    </telerik:RadButton>
                </ContentTemplate>
            </telerik:RadWindow>
            <telerik:RadWindow ID="RadWindow2" runat="server">
                <ContentTemplate>
                    <telerik:RadTextBox ID="RadTextBox1" runat="server">
                    </telerik:RadTextBox>
                </ContentTemplate>
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        RadWindow2.VisibleOnPageLoad = true;
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gabriel
    Gabriel avatar
    3 posts
    Member since:
    Jul 2013

    Posted 12 Feb 2014 in reply to Shinu Link to this post

    Thanks, it does work. Is there a way to do it without the postback?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Feb 2014 in reply to Gabriel Link to this post

    Hi Gabriel,

    Please do the following modification in the above code that I posted.

    ASPX:
    ...
     <telerik:RadButton ID="RadButton1" runat="server" Text="Next Page" AutoPostBack="false"  OnClientClicked="Click">
    </telerik:RadButton>
    ...

    JavaScript:
    <script type="text/javascript">
        function Click(sender, args) {
            var win = $find("<%=RadWindow2.ClientID %>");
            win.show();
        }
    </script>

    Thanks,
    Shinu.
  6. Gabriel
    Gabriel avatar
    3 posts
    Member since:
    Jul 2013

    Posted 13 Feb 2014 in reply to Shinu Link to this post

    It does work but I loose the AsyncUpload functionality since the FileUploaded of the control happen at the PostBack. I need some information from the file to show on the second page.

    I'll try to find my way around it so the user does not sees too much postback
  7. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Feb 2014 in reply to Gabriel Link to this post

    Hi Gabriel,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"  OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    </telerik:RadAjaxManager>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <Windows>
            <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true">
                <ContentTemplate>
                    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server"  TargetFolder="uploads" OnClientFileUploaded="OnClientFileUploaded1">
                    </telerik:RadAsyncUpload>
                    <telerik:RadButton ID="RadButton1" runat="server" Text="Next Page"        AutoPostBack="false" OnClientClicked="Click">
                    </telerik:RadButton>
                </ContentTemplate>
            </telerik:RadWindow>
            <telerik:RadWindow ID="RadWindow2" runat="server">
                <ContentTemplate>
                    <asp:Label ID="Lable1" runat="server" Text="Uploded File"></asp:Label>
                    <telerik:RadTextBox ID="RadTextBox1" runat="server"  OnLoad="RadTextBox1_Load">
                    </telerik:RadTextBox>
                </ContentTemplate>
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

    JavaScript:
    <script type="text/javascript">
        function Click(sender, args) {
            var win = $find("<%=RadWindow2.ClientID %>");
            win.show();
        }
        function OnClientFileUploaded1(sender, args) {
            $find('<%= RadAjaxManager1.ClientID %>').ajaxRequest();
        }
    </script>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        RadWindow2.VisibleOnPageLoad = true;
    }
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        //server method for uploading file into target folder...
    }
    protected void RadTextBox1_Load(object sender, EventArgs e)
    {
        StringBuilder Uploadedfile = new StringBuilder();
        string path = Path.Combine(Server.MapPath(RadAsyncUpload1.TargetFolder));
        DirectoryInfo d = new DirectoryInfo(path);
        FileInfo[] Files = d.GetFiles();
        foreach (FileInfo file in Files)
        {
            Uploadedfile.Append(file.Name);
        }
        RadTextBox1.Text = Uploadedfile.ToString();
    }

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017