Need to Put Line Breaks in the Product Description.

Last post 06-09-2009 11:28 PM by casajr. 3 replies.

Sort Posts:

  • Need to Put Line Breaks in the Product Description.

    06-09-2009, 6:18 PM
    • Member
      point Member
    • casajr
    • Member since 06-01-2009, 6:10 AM
    • Posts 4

    I need to put line breaks in the product description.  I'm using XML for now.  My product descriptions use bullet points, so I need line breaks.  I guess this would also apply to multi-paragraph descriptions.  For Example, I would like to see

    Product Name
    Description
    - Feature 1
    - Feature 2

    What I get now is Description -Feature1 -Feature2.

    I have tried \n\r in the description, but they get displayed litterally (Description\n\r-Feature1\n\r-Feature2).  I have also tried <br />, but that gives me a configureation error.

    Is this something that must be done in VB?  If so, how.  I need the line breaks, I hope someone can help.

  • Re: Need to Put Line Breaks in the Product Description.

    06-09-2009, 6:30 PM
    • Member
      370 point Member
    • Nowman
    • Member since 12-14-2008, 3:44 AM
    • Posts 131

    what is the container that you are pushing this test to?  a label?

    try Environment.NewLine, <br />, <br>, \v, (char)11, or \r\n and see if any work.

    if not let me know what the configuration error is.

    If this post is answer of your question then don't forgot to Click Mark As Answer
  • Re: Need to Put Line Breaks in the Product Description.

    06-09-2009, 10:56 PM
    • Member
      point Member
    • casajr
    • Member since 06-01-2009, 6:10 AM
    • Posts 4

    Thank you for replying.  However, I'm not sure how to properly answer your question.

    The data string is in an xml file which is read by a .aspx file.  The item Description is read by an EVAL command within asp:DetailsView.  Code is below.

    <div id="content-main-three-column">

    <asp:ObjectDataSource ID="ObjectDataSourceItem" runat="server" SelectMethod="GetItem"

    TypeName="Catalog">

    <SelectParameters>

    <asp:QueryStringParameter Name="itemId" QueryStringField="itemId" Type="string" DefaultValue="" />

    </SelectParameters>

    </asp:ObjectDataSource>

    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="false" AllowPaging="false"

    BorderWidth="0" BorderColor="white" DataSourceID="ObjectDataSourceItem">

    <Fields>

    <asp:TemplateField>

    <ItemTemplate>

    <h1>

    <%#Eval("Title")%>

    </h1>

    <br />

    <asp:Image ID="Image1" CssClass="photo-border" runat="server" ImageUrl='<%# "images/" + Eval("ImageUrl") %>'

    AlternateText='<%#Eval("ImageAltText")%>' />

     

    <br />

    <h2>

    <%# Eval("Price","{0:C}")%>

    </h2>

    <br />

    <%# Eval("Description")%>

    <br />

     

    <br />

    In Stock:

    <%
    # IIf(Eval("InStock")= true, "Yes", "No") %>

    <hr />

    <br />

    <asp:Image ID="Image2" CssClass="photo-border" runat="server" ImageUrl='<%# "images/" + Eval("ColorTableUrl") %>'

    AlternateText='<%#Eval("ImageAltText")%>' />

     

    </ItemTemplate>

    </asp:TemplateField>

    </Fields>

    </asp:DetailsView>

    <a href="Items.aspx">Return to All Items</a><img src="images/arrow.gif" alt="" />

    </div>

    <!-- END MAIN COLUMN -->

     I'm wondering if something different than EVAL should be used.  I'm wondering how to change the text from green back to black.

  • Re: Need to Put Line Breaks in the Product Description.

    06-09-2009, 11:28 PM
    Answer
    • Member
      point Member
    • casajr
    • Member since 06-01-2009, 6:10 AM
    • Posts 4

    OK, I fixed it.  The solution is to change the

    <%# Eval("Description")%> to

    <%# Eval("Description").ToString().Replace(Environment.NewLine,"<br />") %>

    Thanks for pointing me in the direction of Environment.NewLine.  I found a link that explains this fully.

    http://www.mikesdotnetting.com/Article.aspx?ArticleID=20

Page 1 of 1 (4 items)