Formatting a post without changing the xml file.

Topics: ASP.NET 2.0, Business Logic Layer
Jul 17, 2008 at 1:56 PM
I am trying to format a post so if the post is over X number of characters, it will remove the additional chars past X, and a append '...' at the the end. A reader will have to click on the post's link to go to the post's view and see the message in its entirety.

I have all the code in place, and in theory it works very well. However whenever I change the looking of the post, it will edit the 'contents' field in the xml file, therefore forever changing the post to the formatted version.

I realize that the problem lies within this code:

postView.Post.Content = postView.Post.Content.Substring(0, i + 4).Trim() + "...";

, as I change the Post.Content property, it will change the post for good. I have also tried to save the original content in a new string, format the content so it should render with the '...', then replace the contents with the saved string - but this seems to undo my formatting. I cannot seem to figure out a method to accomplish this.
Jul 17, 2008 at 8:06 PM
You can use [more] to break post anywhere you like, if I understood your requirements.
Jul 21, 2008 at 1:39 PM
I cannot figure out how to break the post. The only way I see to edit the post is to change the post's 'content' property. If I add in [more] to that, it will change the post's xml's content property, losing the rest of the post.
Jul 21, 2008 at 2:23 PM
Ah, just found that its a build in feature to break post on '[more]'. No more help needed.