Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fredrik 89 posts 108 karma points
    Apr 25, 2011 @ 19:28
    Fredrik
    0

    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?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 25, 2011 @ 19:30
    Jan Skovgaard
    0

    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

  • Fredrik 89 posts 108 karma points
    Apr 26, 2011 @ 08:05
    Fredrik
    0

    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?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 26, 2011 @ 08:21
    Jan Skovgaard
    0

    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

  • Fredrik 89 posts 108 karma points
    Apr 28, 2011 @ 11:42
    Fredrik
    0

    Problem was solved by using a Html Decode method when the property value was set

  • Fredrik 89 posts 108 karma points
    Apr 28, 2011 @ 12:56
    Fredrik
    0

    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?

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Apr 28, 2011 @ 13:22
    Michael Latouche
    1

    Hi Fred,

    I guess you can do a .Replace("\r\n"n "<br/>") on the property value, or something similar?

    Cheers,

    Michael.

  • Fredrik 89 posts 108 karma points
    Apr 29, 2011 @ 09:11
    Fredrik
    0

    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

     

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Apr 29, 2011 @ 09:54
    Michael Latouche
    0

    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:

    var description = product.GetProperty(reqProperty).Value.ToString().Replace("\n","<br/>");
    DescriptionLabel.Text = description;

    Or maybe you will need to HtmlDecode or something.

    Hope this helps.

    Cheers,

    Michael.

     

  • Fredrik 89 posts 108 karma points
    Apr 29, 2011 @ 10:00
    Fredrik
    0

    Well it actually looks like this:

    protected string productInfo(string articleNr, string reqProperty, Node product)
            {
                if (reqProperty == "image" || reqProperty == "pDF")
                {
                    if (!string.IsNullOrEmpty(product.GetProperty(reqProperty).Value))
                    {
                        Media file = new Media(int.Parse(product.GetProperty(reqProperty).Value));
                        return file.getProperty("umbracoFile").Value.ToString();
                    }
                }
                else
                {
                    return product.GetProperty(reqProperty).Value.ToString();
                }
                return "";
            }


    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);

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Apr 29, 2011 @ 10:16
    Michael Latouche
    0

    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 :

    DescriptionLabel.Text = Server.HtmlDecode(product.description.Replace("\n","<br/>"));

    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 "&lt;br/&gt;".

    Cheers,

    Michael.

Please Sign in or register to post replies

Write your reply to:

Draft