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

Error after rotate and reset changes

1 Answer 63 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Nitin
Top achievements
Rank 1
Nitin asked on 10 Dec 2013, 12:49 PM
Working Code: I have a Grid, and it has list of filename's with radio button. If I select a radio button, I can display image for the filename in the RadImageEditor. If I change the radio button or click another row, the image is updated properly. When image is displayed and If I click on zoom in zoom out, and then reset, the image is displayed in its original form the way it was loaded.
1) The problem comes when I first rotate an image, then click on reset changes , the image does not come to its original form the way it was initially loaded.
2) Continuing the step 1, if I now try to change radiobutton so try to load another image, an error is thrown.

Let me know any better way or possible solution to this issue. The demo does not give proper information for this issue, so putting in this forum.
 Markup Code:
<%@ Page Title="Home Page" Language="vb"   AutoEventWireup="false"   CodeBehind="Default.aspx.vb" Inherits="DocumentMgr._Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"  >
    <title></title>
   
     <script type="text/javascript">
         function OnClientCommandExecuting(sender, eventArgs) {

             if (eventArgs.get_commandName() == "Reset") {                 
                 var imgEditor = $find("<%=rie.ClientID %>");
                 imgEditor.getEditableImage()._finishReset();
                 eventArgs.set_cancel(true);
             }
             return false;
         }
         
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
   <%--<asp:FileUpload ID="fup" runat="server" />
    <asp:Button ID="submit" runat="server"  Text="Submit" OnClick="Submit_Click" />--%>
     <asp:ScriptManager ID="sm" runat="server"  ></asp:ScriptManager>
    <asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <telerik:radgrid id="grTL" skin="Office2010Silver" allowfilteringbycolumn="false"  
        width="100%" height="150px" showstatusbar="true" runat="server" allowpaging="True"
        allowsorting="True" enableajax="True" allowcustompaging="false" pagesize="23"
        editformitem="false" autogeneratecolumns="false" enablecolumnsviewstate="false"
        autogenerateeditcolumn="false" enableariasupport="true" MasterTableView-DataKeyNames="ID"
        >
       
        <MasterTableView HeaderStyle-Font-Bold="true" ShowFooter="False" AllowNaturalSort="false"
                                    EditMode="InPlace" CommandItemDisplay="None" Summary ="">
            <Columns>
                <telerik:GridTemplateColumn UniqueName="Select" HeaderText="" HeaderStyle-Width="40"
                    HeaderStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:RadioButton ID="rbSelect" AutoPostBack="true" EnableTheming="true" Font-Bold="true"
                            runat="server" OnCheckedChanged="rbSelect_CheckedChanged" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                
                 <telerik:GridTemplateColumn HeaderText="FileName" >
                    <ItemTemplate>
                        <asp:Label ID="lblFileName" runat="server" Width="200px" Text='<%# Eval("FileName") %>'></asp:Label>                        
                    </ItemTemplate>
                    <EditItemTemplate>
                         <asp:Label ID="lblEFileName" runat="server" Width="200px" Text='<%# Eval("FileName") %>'></asp:Label>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Information" >
                    <ItemTemplate>
                        <asp:Label ID="lblInfo" runat="server" Width="200px" Text='<%# Eval("Information") %>'>
                        </asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadTextBox ID="txtEditInfo" runat="server"  Width="200px" Text='<%# Bind("Information") %>' TabIndex="1" />                                                
                    </EditItemTemplate>
                   
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings AllowColumnsReorder="true">
            <Scrolling AllowScroll="true" UseStaticHeaders="true" FrozenColumnsCount="3" />
            <Resizing AllowColumnResize="True" AllowRowResize="false" ResizeGridOnColumnResize="false"
                ClipCellContentOnResize="true" EnableRealTimeResize="false" />
        </ClientSettings>
    </telerik:radgrid>
 

<telerik:RadImageEditor ID="rie" runat="server" EnableResize="true"    
  Width="100%" Height="500px" EnableEmbeddedScripts="true"   OnClientCommandExecuting="OnClientCommandExecuting"   
ToolsFile="Basic.xml"  >
 
</telerik:RadImageEditor>
    </ContentTemplate>
    </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Code Behind:
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            BindData()
        End If
    End Sub

    Private Sub BindData()
        grTL.DataSource = GetListOfImages()
        grTL.DataBind()
    End Sub
    Private Function GetListOfImages() As List(Of FileData)
        Dim images = New List(Of String)()
        Dim arr As List(Of FileData) = New List(Of FileData)
        Dim files As Files = New Files
        Try
            arr = files.GetFileWoAttachment()
            ' Get a list of FileName with extension to be displayed in Grid.
            
            
        Catch ex As Exception
            'log exception

        End Try

        Return arr

    End Function
    Protected Sub rbSelect_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)


        Dim bCAllToday As Boolean = False
        'Session("RowIndex") = 0

        Dim item As GridDataItem = DirectCast(TryCast(sender, RadioButton).NamingContainer, GridDataItem)
        Dim rdBtn As RadioButton = TryCast(sender, RadioButton)

        If rdBtn.Checked Then
            Session("RowIndex") = item.ItemIndex
            item.Selected = True
            rie.ImageUrl = "ShowImg.ashx?ID=" + CType(grTL.SelectedValues("ID"), String)
            Session("RowIndex") = CType(grTL.SelectedValues("ID"), String)
            rie.DataBind()

          
        End If

    End Sub

HANDLER:

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Dim my_Id As Int32
        If context.Request.QueryString("ID") IsNot Nothing Then
            my_Id = Convert.ToInt32(context.Request.QueryString("ID"))
            context.Response.ContentType = "image/png"
            context.Response.Buffer = True
            Dim strm As Stream = ShowEmpImage(my_Id)
            Dim bmp As Bitmap = New Bitmap(strm)
            bmp.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png)
          
        End If
        
    End Sub

    Public Function ShowEmpImage(ByVal my_Id As Integer) As Stream
        Dim fs As Files = New Files()
        Dim fdata As FileData = fs.GetFile(my_Id)
        'Attachment property defined in Class  As Byte()
        If (fdata.Attachment IsNot Nothing) Then
            Return New MemoryStream(DirectCast(fdata.Attachment, Byte()))
        Else
            Return Nothing
        End If

    End Function

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 13 Dec 2013, 12:06 PM
Hi Nitin,

I am afraid that the provided information was not enough for me to reproduce the issue on my side, because of many missing references (like classes, database, etc.). With the current information I could only guess what might be causing the problem and propose the following solutions:
  • Try using RadAjaxManager instead an update panel. You can take a look at the approach used in this live demo, also loading the content from a data base: Using Custom Content Provider
  • Disable the page validation by setting the ValidateRequest property of the <%@ Page directive to "false"

If non of the suggestions above helps in solving the case, I will need to replicate and examine the issue locally. You can see how to prepare a sample fully runnable project reproducing the problem in the following blog post: Isolating a problem in a sample project

Kind regards,
Veselina Raykova
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ImageEditor
Asked by
Nitin
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or