Strange Error when saving a from a Radeditor Column

8 posts, 0 answers
  1. Daniel
    Daniel avatar
    4 posts
    Member since:
    Jan 2013

    Posted 30 Jan 2013 Link to this post

    We have a strange error, not sure if its related to OpenAccess or Radgrid/Radeditor.
    This is the code:

    <telerik:OpenAccessLinqDataSource ID="dsPages"
                                                          runat="server"
                                                          ContextTypeName="carcompete.ef.EntitiesModel"
                                                          EnableDelete="True"
                                                          EnableInsert="True"
                                                          EnableUpdate="True" EntityTypeName="" OrderBy="Name" ResourceSetName="Pages">
                        </telerik:OpenAccessLinqDataSource>
     
                        <telerik:OpenAccessLinqDataSource ID="OpenAccessDataSource2"
                                                          Runat="server"
                                                          ContextTypeName="carcompete.ef.EntitiesModel" EnableDelete="True"
                                                          EnableInsert="True" EnableUpdate="True" EntityTypeName=""
                                                          ResourceSetName="Contents"
                                                          Where="Pages_PageId == @PageId">
                            <WhereParameters>
                                <asp:Parameter Name="PageId" Type="Int32" />
                            </WhereParameters>
                        </telerik:OpenAccessLinqDataSource>
     
                        <telerik:RadGrid ID="RadGrid1" runat="server"  DataSourceID="dsPages" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0" GridLines="None" Skin="MetroTouch">
                            <HeaderContextMenu>
                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                            </HeaderContextMenu>
                            <MasterTableView AutoGenerateColumns="False" DataKeyNames="PageId" DataSourceID="dsPages" CommandItemDisplay="TopAndBottom">
                                <DetailTables>
                                    <telerik:GridTableView runat="server"  CommandItemDisplay="TopAndBottom"  EditMode="PopUp" DataSourceID="OpenAccessDataSource2" DataKeyNames="ContentId" AutoGenerateColumns="False" AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" >
                                        <ParentTableRelation>
                                            <telerik:GridRelationFields DetailKeyField="PageId" MasterKeyField="PageId" />
                                        </ParentTableRelation>
     
                                        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
                                        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
     
                                        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
     
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="ContentId" DataType="System.Int32" FilterControlAltText="Filter ContentId column" HeaderText="ContentId" ReadOnly="True" SortExpression="ContentId" UniqueName="ContentId">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Pages_PageId" FilterControlAltText="Filter Pages_PageId column" HeaderText="Pages_PageId" SortExpression="Pages_PageId" UniqueName="Pages_PageId">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Position" FilterControlAltText="Filter Position column" HeaderText="Position" SortExpression="Position" UniqueName="Position">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridHTMLEditorColumn DataField="Html" FilterControlAltText="Filter Html column" HeaderText="Html" SortExpression="Html" UniqueName="Html">
                                            </telerik:GridHTMLEditorColumn>
                                        </Columns>
                                         
     
                                         
     
                                        <EditFormSettings>
                                            <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                        </EditFormSettings>
                                    </telerik:GridTableView>
                                </DetailTables>
     
                                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
                                <RowIndicatorColumn>
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </RowIndicatorColumn>
                                <ExpandCollapseColumn Visible="True">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </ExpandCollapseColumn>
     
                                <Columns>
                                    <telerik:GridBoundColumn DataField="PageId" DataType="System.Int32" FilterControlAltText="Filter PageId column" HeaderText="PageId" ReadOnly="True" SortExpression="PageId" UniqueName="PageId">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Name" SortExpression="Name" UniqueName="Name">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Leftclass" FilterControlAltText="Filter Leftclass column" HeaderText="Leftclass" SortExpression="Leftclass" UniqueName="Leftclass">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Rightclass" FilterControlAltText="Filter Rightclass column" HeaderText="Rightclass" SortExpression="Rightclass" UniqueName="Rightclass">
                                    </telerik:GridBoundColumn>
                                </Columns>
     
                                <EditFormSettings>
                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                </EditFormSettings>
     
                            </MasterTableView>
                            <FilterMenu>
                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                            </FilterMenu>
                        </telerik:RadGrid>

    Insert and Update in MasterTableView works fine
    Insert and Update in Detailview works fine too, as long the text in the telerik:GridHTMLEditorColumn  is not long.
    As soon we want to edit or insert a long html code, we get that strange error:

    The database version of the object identified by the specified key is newer than the version specified in the key.
     
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
     
    Exception Details: Telerik.OpenAccess.Exceptions.OptimisticVerificationException: The database version of the object identified by the specified key is newer than the version specified in the key.
     
    Source Error:
     
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
     
    Stack Trace:
     
     
    [OptimisticVerificationException: The database version of the object identified by the specified key is newer than the version specified in the key.]
       OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.GetObjectByKey(ObjectKey key) +240
       OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.GetObjectByKey(ObjectKey key) +55
       OpenAccessRuntime.ObjectScope.GetObjectByKey(ObjectKey key) +55
       Telerik.OpenAccess.OpenAccessContextBase.GetObjectByKey(ObjectKey key) +255
       Telerik.OpenAccess.Web.OpenAccessLinqDataSourceView.GetObjectByKeys(IDictionary keys) +143
       Telerik.OpenAccess.Web.OpenAccessLinqDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +192
       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +87
       Telerik.Web.UI.GridTableView.PerformUpdate(GridEditableItem editedItem, Boolean suppressRebind) +381
       Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +2002
       Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +211
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +71
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       Telerik.Web.UI.GridEditFormItem.OnBubbleEvent(Object source, EventArgs e) +372
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +156
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9642898
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

    strange, as we cant see why this have to do with a object key, as the same row edit or insert works, with a smaller text

    We use openaccess free version and are evaluating the UI controls
    Tks
    Daniel
  2. Daniel
    Daniel avatar
    4 posts
    Member since:
    Jan 2013

    Posted 30 Jan 2013 Link to this post

    Hope this helps to find the problem:
    Using a separate Radgrid, select the contentid there and load the content into the Radeditor and Save then via OpenAccess manually works with the same html, which gives the problem in the scenario described above:

    Dim cId As Int16 = DirectCast(RadGrid1.SelectedItems(0), GridDataItem).GetDataKeyValue("ContentId").ToString()
     
           
           Using dbContext As New EntitiesModel()
     
               Dim co As ef.Content = dbContext.Contents.Where(Function(c) c.ContentId = cId).FirstOrDefault()
     
               co.Html = RadEditor1.Content
     
               dbContext.SaveChanges()
     
     
           End Using
  3. DevCraft banner
  4. Daniel
    Daniel avatar
    4 posts
    Member since:
    Jan 2013

    Posted 31 Jan 2013 Link to this post

    as nobody answering here... I found the problem

    putting  ValidateRequest="false" in Page Directive of the aspx file resolved the problem.

  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 01 Feb 2013 Link to this post

    Hello Daniel,

    I am glad to see that you have found a workaround.

    This error is related to the optimistic concurrency control mechanism used by the OpenAccessLinqDataSource during update operations. To verify that the original object has not been changed since it was loaded in memory, OpenAccess stores the field values read from the database inside an object key instance for each object. It seems the value of your Html field is not correctly serialized in the object key, which leads to a difference during the concurrency check later. Could you please tell us how long the html text is when the error occurs, so we can try to reproduce this on our side?
    Thank you in advance for your cooperation.

    All the best,
    Alexander
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
  6. Daniel
    Daniel avatar
    4 posts
    Member since:
    Jan 2013

    Posted 01 Feb 2013 Link to this post

    Hi, tks for answering

    A i wrote, the only thing i did, and afer it worked fine, was:
    putting  ValidateRequest="false" in Page Directive of the aspx file 

    So i think the problem was not the size, but that  it was html code, interpreted from IIS as something bad (well, could be...)
  7. walter ciceri
    walter ciceri avatar
    4 posts
    Member since:
    May 2011

    Posted 06 Apr 2015 in reply to Alexander Link to this post

    Hi

    I found the same error when added this code :

    protected void RadListView1_ItemDataBound(object sender, RadListViewItemEventArgs e)
           {
     
                if (e.Item is RadListViewEditableItem )
                {
                    RadTextBox tbx = (RadTextBox)e.Item.FindControl("linkagent");
                    Control par = (Control)tbx.Parent;
                    RadAutoCompleteBox cnt = (RadAutoCompleteBox)par.FindControl("RadAutoCompleteBox1");
                    String[] lines = new string[6];
                    lines = Regex.Split(tbx.Text, ";");
     
     
                    for (int i = 0; i < lines.Length; i++)
                    {
                        cnt.Entries.Insert(0, new AutoCompleteBoxEntry(lines[i], lines[i]));
                    }
                }
                
           }

  8. Viktor Zhivkov
    Admin
    Viktor Zhivkov avatar
    291 posts

    Posted 09 Apr 2015 Link to this post

    Hi walter,

    Are you using Telerik Data Access in you project and which version?
    If you do can you give us a bit more details about the whole setup as there is very little information what is what in the code snippet. Details that will be helpful include:
    • how is your RadListView1 bound?
    • what is cnt?
    • what is cnt.Entries?
    • is AutoCompleteBoxEntry a persistent type or not?
    • are there any lines that may be considered harmful to ASP.NET runtime (for example containing pieces of javascript or HTML)
    Have you tried the suggested solution to set  ValidateRequest="false" in your page/control?

    Regards,
    Viktor Zhivkov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  9. walter ciceri
    walter ciceri avatar
    4 posts
    Member since:
    May 2011

    Posted 09 Apr 2015 in reply to Viktor Zhivkov Link to this post

    Hi Viktor

    I'm sorry , but I think that the problem is difficult to localize . I tried deleting the control "AutoComplete", clean-compile, and replace with a new one the problem was resolved . 
    All things considered, I sure that something don't work properly. For example .. sometimes when I change inside a Autocomplete a delimiter from ";" to "," the control stop to be recognized from the library.
    Probably the problem is inside the RadListView in databound. Below a new problem discovered :

    If I insert into the ItemDataBound function the line "btedit.Visible = true ;"  LinkButton don't fire edit. Without this line work fine.

    protected void RadListView1_ItemDataBound(object sender, RadListViewItemEventArgs e)
           {
               if (e.Item is RadListViewDataItem)
               {
                   LinkButton btedit = (LinkButton)e.Item.FindControl("EditButton");
                   btedit.Visible = true ;
               }
           }

    <ItemTemplate>
                <div class="col-lg-4">
                   <div class="contact-box">
     
                     <a href="RedirectProfile.aspx?id=<%# Eval("id")%>&tab=company&mat=<%# Eval("matri") %>">
                       <div>
                          <%# Eval("Steap_lead") %>
                       </div>
                       <div class="col-sm-4">
                           <div class="text-center">
                               <img alt="image" class="img-circle m-t-xs img-responsive" src="http:\\repository.b4its.com\loadimgStr.ashx?width=200&ti=CompanyLogos&im=<%#Session["CRMselected"].ToString()%>_cont_company_<%# Eval("id") %>.jpg">
                               <div class="m-t-xs font-bold">Rec.<%# Eval("id") %></div>
                               <div class="m-t-xs font-bold"><%# Eval("class_empire") %></div>
                           </div>
                       </div>
                       <div class="col-sm-8">
                           <div style="height: 45px">
                           <h4><strong><%# Eval("Ragione_sociale") %></strong></h4>
                           </div>
                           <p><i class="fa fa-map-marker"></i> <%# Eval("main_town") %></p>
                           <address>
                               <div style="height: 35px">
                                 <strong><%# Eval("main_address") %></strong><br>
                               </div>
                                <%# Eval("main_zip") %> - <%# Eval("main_town") %><br />
                                <%# Eval("main_provincia_sigla") %>
                                <%# Eval("main_provincia_esteso") %>  <%# Eval("main_region") %><br>
                                <%# Eval("main_country") %><br>
                               
                           </address>
                       </div>
                             <asp:LinkButton runat="server" CommandName="Edit" Text="<i class='fa fa-edit'></i>" ID="EditButton" CssClass="btn btn-outline btn-primary dim fa" ToolTip="Modifica veloce" CausesValidation="False" />
                                                    
                       <div class="clearfix"></div>
                     </a>
                       
                   </div>
      </div>



     

Back to Top
DevCraft banner