Developer forum

Forum » Templates » Razor removes quotes

Razor removes quotes

Anders Ebdrup
Reply

Hi DW,

 

I have an issue with a custom modules containing a rich text editor. The value are set on the template in the module with:

            template.SetTag("AbArticle2", Properties.Values["AbArticle2"].ToString());


And I am outputting the values in my template by:

            @GetValue("AbArticle1")


But when outputting my qoutes are gone from the rich text area. E.g.

<a href="/Files/Filer/x.pdf" target="_blank">See x</a>

is outputted as:

<a href=/Files/Filer/x.pdf target=_blank>See x</a>

which causes problems in some browsers

Best regards, Anders


Replies

 
Mikkel Ricky
Reply

I've never experienced this and Razor should not be doing this. Are you sure that the value you use in SetTag contains the quotes? Does it work with other rich text fields, e.g. on paragraph?

Which version of Dynamicweb are you running?

Best regards,
Mikkel

 
Nicolai Høeg Pedersen
Reply

I think you are using the RTE in the _edit.aspx file for the paragraph settings?

Those settings are saved to ParagraphModuleSettings field on the paragraph table and that is what removes the quotes, I think.

The template engine or razor template base manipulates the string.

 
Morten Bengtson
Reply

Hi Anders,

I don't think this is a Razor issue. It is more likely related to the use of Properties, which I guess is your module settings on a paragraph?

Properties are stored as XML in the database and when serialized into XML the quotation marks are removed (weird hack in DW). You can try to work around this by encoding the value before you store it (HtmlEncode) and then decode when you read the value (HtmlDecode) - or you can store the values somewhere else ;-)

However, quotes around attribute values are optional in HTML5 as long as there are no unencoded characters in the value, so it shouldn't cause any issues in any browser AFAIK.

EDIT: Oh, I see the problem now. DW is unable to parse the links correctly after it has removed the quotation marks.

 
Anders Ebdrup
Reply

Hi all,

 

Thanks for very quick responses!

@Morten: How do I encode the module settings before these are saved to the database? As this is now done automatically by DW.

 

Best regards, Anders

 
Remi Muller
Reply
This post has been marked as an answer

Maybe this topic http://developer.dynamicweb.com/forum/development/custommodulesettings-double-quotes-removed-from-value.aspx can help?

Depending on how u save your data in the custom module.

Votes for this answer: 1
 
Anders Ebdrup
Reply

Hi Remi,

Thank you very much - that did the trick! smiley

 

Best regards, Anders

 

You must be logged in to post in the forum