Keep RadWindow open after completing server site event

2 posts, 1 answers
  1. Pankaj
    Pankaj avatar
    1 posts
    Member since:
    Nov 2013

    Posted 14 Feb 2014 Link to this post

    Hi
    I am using RadWindow which contains RadAsyUpload in asp.net update panel , image control and button when i select image in RadasyUpload image get uploaded and preview is displaying in image control, but problem is that when image uploaded RadWindow get close and to view image i have to open Radwindow again , how could i keep open RadWindow after displaying image and close it when i click on close button
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

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

    Hi Pankaj,

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

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnablePageHeadUpdate="false">
    </telerik:RadAjaxManager>
    <telerik:RadWindow ID="Radwindow1" runat="server" VisibleOnPageLoad="true">
        <ContentTemplate>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <telerik:RadAsyncUpload ID="AsyncUpload1" runat="server"    OnClientFilesUploaded="OnClientFilesUploaded" OnFileUploaded="AsyncUpload1_FileUploaded"    AllowedFileExtensions="jpg,png,gif,bmp" />
                    <telerik:RadImageEditor ID="RadImageEditor1" runat="server" Width="680"   Height="450"  ImageUrl="~/Images/350chev_conrod265_76.jpg" OnImageLoading="RadImageEditor1_ImageLoading">
                    </telerik:RadImageEditor>
                </ContentTemplate>
            </asp:UpdatePanel>
        </ContentTemplate>
    </telerik:RadWindow>

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

    C#:
    protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
    {
        RadImageEditor1.ResetChanges();
        Context.Cache.Remove(Session.SessionID + "UploadedFile");
        using (Stream stream = e.File.InputStream)
        {
            byte[] imgData = new byte[stream.Length];
            stream.Read(imgData, 0, imgData.Length);
            MemoryStream ms = new MemoryStream();
            ms.Write(imgData, 0, imgData.Length);
            Context.Cache.Insert(Session.SessionID + "UploadedFile", ms, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero);
        }
    }
    protected void RadImageEditor1_ImageLoading(object sender, ImageEditorLoadingEventArgs args)
    {
        if (!Object.Equals(Context.Cache.Get(Session.SessionID + "UploadedFile"), null))
        {
            using (EditableImage image = new EditableImage((MemoryStream)Context.Cache.Get(Session.SessionID + "UploadedFile")))
            {
                args.Image = image.Clone();
                args.Cancel = true;
            }
        }
    }

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