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

AsyncUpload and multiple RadWindow

5 Answers 64 Views
Window
This is a migrated thread and some comments may be shown as answers.
Gabriel
Top achievements
Rank 1
Gabriel asked on 11 Feb 2014, 09:43 PM

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,

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Feb 2014, 02:50 AM
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.
0
Gabriel
Top achievements
Rank 1
answered on 12 Feb 2014, 02:32 PM
Thanks, it does work. Is there a way to do it without the postback?
0
Shinu
Top achievements
Rank 2
answered on 13 Feb 2014, 02:45 AM
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.
0
Gabriel
Top achievements
Rank 1
answered on 13 Feb 2014, 02:30 PM
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
0
Accepted
Shinu
Top achievements
Rank 2
answered on 17 Feb 2014, 04:01 AM
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.
Tags
Window
Asked by
Gabriel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Gabriel
Top achievements
Rank 1
Share this question
or