guestbook with an xml database - problem

Last post 05-09-2008 11:00 AM by gtk. 6 replies.

Sort Posts:

  • guestbook with an xml database - problem

    05-09-2008, 4:33 AM
    • Loading...
    • gtk
    • Joined on 05-08-2008, 5:38 PM
    • Posts 6

    hi,

    i created a guestbook with an xml database. User submits the post, the post is saved in the xml file. To view the gusetbook, i use a databind statement in html file like this:

     <%# DataBinder.Eval(Container.DataItem, "elementOfXmlFile") %> 

    The problem is when you try to view the guestbook, the text from the xml file dislpayed all in one line, without the format specified by the user (i mean no paragraphs, no new line etc). I checked the xml file, and noticed that there is a new line character when the user press enter.

     

    How can i resolve the problem?  

  • Re: guestbook with an xml database - problem

    05-09-2008, 5:07 AM

    Hello,

    You have to convert these into HTML tags when you save the entry (post).

     

    Replace("text goes here", Environment.NewLine , "<br />")
     

    After that you will be able to see the requested formating in the browser.

     

    HTH
    Regards

  • Re: guestbook with an xml database - problem

    05-09-2008, 6:20 AM
    • Loading...
    • gtk
    • Joined on 05-08-2008, 5:38 PM
    • Posts 6

     thanks for your answer.

    I have tried to insert explicity the <br /> in the xml file but then the databind.Eval statement doesnt work (it complaints about the <br /> ).Confused

  • Re: guestbook with an xml database - problem

    05-09-2008, 6:49 AM

    Yes, it should

    Encode that using Server.Encode method and when you want to display it in the asp.net page use server.decode

    Did you try that? 

  • Re: guestbook with an xml database - problem

    05-09-2008, 9:00 AM
    • Loading...
    • gtk
    • Joined on 05-08-2008, 5:38 PM
    • Posts 6

    I have to encode the xml file and to decode it when displaying the html content?? How to do  that? I think that if i try to encode the xml file, the function that binds the xml file to the DataSet and after to the Repeater doesnt work.
     

  • Re: guestbook with an xml database - problem

    05-09-2008, 9:25 AM
    Answer

     Try this

     
    Replace("text goes here", Environment.NewLine , Server.HtmlEncode("<br />"))
    
    
     
    When you read retrieve the data again use Server.HtmlDecode(datafield) 
     
    Regards 


     

  • Re: guestbook with an xml database - problem

    05-09-2008, 11:00 AM
    • Loading...
    • gtk
    • Joined on 05-08-2008, 5:38 PM
    • Posts 6

     Now its OK Cool

    Finally, i encoded the post before its saved in xml, and to view it, i decoded it like this:

    <%# Server.HtmlDecode(DataBinder. Eval(Container.DataItem, "myElement").ToString())) %> 

     

    Thanks for your time man Big Smile 

Page 1 of 1 (7 items)