Programmatically creating a dynamic content item. What kind

Posted by Community Admin on 04-Aug-2018 00:49

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

All Replies

Posted by Community Admin on 19-Dec-2013 00:00

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.

Posted by Community Admin on 19-Dec-2013 00:00

It was due to a single opening square bracket in my content as in
<a href="[http

Crazy!

I created a new thread www.sitefinity.com/.../simple-malformed-html-markup-can-break-sitefinity-backend

Please fix this.

Posted by Community Admin on 21-Dec-2013 00:00

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

Posted by Community Admin on 23-Dec-2013 00:00

Thanks Nikolay.

Regards,
Michael

This thread is closed