+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Programmatically creating a dynamic content item. What kind of validation does Sitefinity run on the content?

Programmatically creating a dynamic content item. What kind of validation does Sitefinity run on the content?

4 posts, 1 answered
  1. Michael
    Michael avatar
    41 posts
    Registered:
    07 Nov 2013
    19 Dec 2013
    Link to this post
    Sitefinity 6.2.

    My code looks something like:

    DynamicContent dynamicContent = dynamicModuleManager.CreateDataItem(type);
    dynamicContent.SetValue("Content", myHtmlContent);
    dynamicModuleManager.Lifecycle.Publish(dynamicContent);
    dynamicContent.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published");
    dynamicModuleManager.SaveChanges();  // This throws an exception "Length cannot be less than zero. Parameter name: length"

    I am migrating a lot of HTML content. Out of over 2500, only 1 triggers an exception. I looked at the HTML and there does not appear to be anything special. I'm guessing maybe the HTML is malformed. But why would Sitefinity try to do anything with the string I'm setting to my field called "Content"?

    "Content" field is defined as "Long text" with a "Rich text editor" interface.

    Thanks.
  2. Michael
    Michael avatar
    41 posts
    Registered:
    07 Nov 2013
    19 Dec 2013
    Link to this post
    It was due to a single opening square bracket in my content as in
    <a href="[http

    Crazy!

    I created a new thread http://www.sitefinity.com/developer-network/forums/bugs-issues-/simple-malformed-html-markup-can-break-sitefinity-backend

    Please fix this.
    Answered
  3. Nikolay Dimitrov
    Nikolay Dimitrov avatar
    17 posts
    Registered:
    17 Oct 2016
    21 Dec 2013
    Link to this post
    Hi Michael,

    Actually this is a bug. I have logged it and we will do our best to fix it for the next release.
    Sorry for the inconvenience.

    Regards,
    Nikolay Dimitrov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Michael
    Michael avatar
    41 posts
    Registered:
    07 Nov 2013
    23 Dec 2013 in reply to Nikolay Dimitrov
    Link to this post
    Thanks Nikolay.

    Regards,
    Michael
4 posts, 1 answered