0

I have a field called Description in the front end form, it is a textarea where user can type/copy past the text which include line breaks aswell.

From asp.net all this data goes to sharepoint.

Now I have a search page which returns all these values from sharepoint using webserivices in the format of xml.

The problem is that all of the line breaks in the value in replaced with 


I am trying to display the description field values to the label, but its not working I tried below things :

lblDesc.Text = xmlValuesPath.Attribute("ows_Description").Value.Replace("
", "\n");

lblDesc.Text = xmlValuesPath.Attribute("ows_Description").Value.Replace("&#xA;", "</p><p>");

The formatting works fine in a textbox, but nothing seems to be working, kindly help.

3 Answers 3

1

Did you clear out all HTML tags from it?

public static string ClearHTMLTagsFromString(string htmlString)
        {
            string regEx = @"\<[^\<\>]*\>";
            string tagless = Regex.Replace(htmlString, regEx, string.Empty);
            // remove rogue leftovers     
            tagless = tagless.Replace("<", string.Empty).Replace(">", string.Empty);
            tagless = tagless.Replace("Body:", string.Empty);
            return tagless;
        } 
2
  • It doesn't have HTML tags in it. Just that its having formatting issue with label.
    – foo-baar
    Nov 28, 2011 at 12:27
  • Never mind its sorted out. lblDesc.Text = xmlValuesPath.Attribute("ows_Description").Value.Replace("\n", "</p><p>")
    – foo-baar
    Nov 28, 2011 at 12:29
0

Try to replace "&#xA;" with "<br/>" it should work in ASP.NET Label.

0

By default asp.net coverts it to \n .which at the run time wont be parsed by the html code to you just need to replace \n with "

"

xmlValuesPath.Attribute("ows_Description").Value.Replace("\n", "</p><p>")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.