When I create documents programatically, strings that contain special characters are saved as ( for example. ö or ") How can come around this problem?
It is displayed as above in the umbraco content section after creating a umbraco.cms.businesslogic.web.document....how can I set encoding so that it accepts characters like (å,ä,ö,") etc?
Depending on your version of Visual Studio you should be able to go to "File -> Save selected item as"...and from the window that appears here you should be able to select the encoding.
There something I do not quite understand in your code snippet: it seems you call the .Replace method on one of your product properties, without assigning the result to any variable. So in fact this does not do anything concrete I think. Then you assign product.description to your DescriptionLabel, but from what I see in the code, product.description was not changed.
Have you tried something like this:
var description = product.GetProperty(reqProperty).Value.ToString().Replace("\n","<br/>"); DescriptionLabel.Text = description;
Or maybe you will need to HtmlDecode or something.
Sorry for me not understanding correctly, I can imagine you cannot post your full code ;-), but I still do not see the link between the different pieces of code you have posted :-S
If you want to display the product description property which is multi-line, then I guess you must use something like this :
If you want to use the result of your productInfo method, then I guess you must use something like this:
var description = productInfo("123456", "description", product); DescriptionLabel.Text = Server.HtmlDecode(description.Replace("\n","<br/>")); // or do the Replace within yout productInfo method "else" branch
But for the moment, I do not see the link, in your example/problem, between the productInfo method and the fact that you assign the product.description property to the literal. Can you maybe post a little more info to make that link become clear?
Also, I am actually not sure if you need to HtmlDecode, but I am quite sure that HtmlEncode is of no use in this case. HtmlEncoding will replace your "<br/>" to something like "<br/>".
Problems with text
When I create documents programatically, strings that contain special characters are saved as ( for example. ö or ") How can come around this problem?
Hi Frederik
What kind of characters are you creating? And where is it displayed as above?
Are you saving the the file encoded as utf-8?
/Jan
It is displayed as above in the umbraco content section after creating a umbraco.cms.businesslogic.web.document....how can I set encoding so that it accepts characters like (å,ä,ö,") etc?
Depending on your version of Visual Studio you should be able to go to "File -> Save selected item as"...and from the window that appears here you should be able to select the encoding.
Hope this helps.
/Jan
Problem was solved by using a Html Decode method when the property value was set
I have another similiar problem.
When writing text in a textbox multiple, the linebreaks dissapears when adding the property value to a string in visualstudio.
Is there away to output the property value of type 'textbox multiple' through an aspx usercontrol without the linebreaks disappearing?
Hi Fred,
I guess you can do a .Replace("\r\n"n "<br/>") on the property value, or something similar?
Cheers,
Michael.
I have tried various ways of achieving this without any luck.
Critical parts from my code as it looks like right now.
product.GetProperty(reqProperty).Value.ToString().Replace("\n","<br/>");
DescriptionLabel.Text = product.description;
DescriptionLabel is asp:literal and ive tried with all modes(transform, pass through and encode).
Replace does find and replace \n but only show <br/> as text in the output
Hi Fredrik,
There something I do not quite understand in your code snippet: it seems you call the .Replace method on one of your product properties, without assigning the result to any variable. So in fact this does not do anything concrete I think. Then you assign product.description to your DescriptionLabel, but from what I see in the code, product.description was not changed.
Have you tried something like this:
Or maybe you will need to HtmlDecode or something.
Hope this helps.
Cheers,
Michael.
Well it actually looks like this:
So it is not the complete code :). The problem lies somewhere in what in my last entry...
Ive tried html.decode and encode like:
DescriptionLabel.Text = Server:HtmlEncode(product.description);
Hi Fredrik,
Sorry for me not understanding correctly, I can imagine you cannot post your full code ;-), but I still do not see the link between the different pieces of code you have posted :-S
If you want to display the product description property which is multi-line, then I guess you must use something like this :
If you want to use the result of your productInfo method, then I guess you must use something like this:
But for the moment, I do not see the link, in your example/problem, between the productInfo method and the fact that you assign the product.description property to the literal. Can you maybe post a little more info to make that link become clear?
Also, I am actually not sure if you need to HtmlDecode, but I am quite sure that HtmlEncode is of no use in this case. HtmlEncoding will replace your "<br/>" to something like "<br/>".
Cheers,
Michael.
is working on a reply...