-
Formatted Text
I am hoping that someone could point me in the right direction. Here is what I have and would like to do.
I have a web app that I would like to allow users to input very basic formatting which i then can save to a SQL database.
I don't really need the user to fully format only things like Bold, Italics, New lines.. I do not need to allow the user to modify fonts or sizes.
Any advice on how to proceed would be very helpful.. Thanks
-
Re: Formatted Text
You would probably want to use some sort of code system, the same way as a forum does. Forums use [b][/b] for bold, replacing i for italic.
You could so something like that then process the output when you display the information by looking for those tags in text.
I'm unsure is newlines are stored in databases, I believe they are if you are using the correct data type.
Cheers.
-
Re: Formatted Text
Can I use a textbox as SQL server field nvarchar to store this type of text? Including newlines? Then output it in a label?
-
Re: Formatted Text
You can store newlines as I recall but you will not be able to store bold and the like. You would need to develop some sort of tag system, as I described in the last post, if you wish to preserve the formatting.
You could do that on storing the information then decode it when the information is read from the database.
-
Re: Formatted Text
Ok thank you. I follow what you are saying. One last question if you don't mind. I am reading the data from the SQL DB and using a ASP:Repeater control to display the results however it is not recognizing the new line character. I have included the code from the repeater control below.
Code:
<asp:Repeater ID="NewsDisplay" runat="server">
<ItemTemplate>
<b><%# ((DateTime)Eval("Created")).ToString("MM-dd-yyyy") %></b>
<br />
<%# DataBinder.Eval(Container.DataItem,"Title") %>
<br />
<%# DataBinder.Eval(Container.DataItem,"Description") %>
<br />
<asp:HyperLink ID="LinkButton1" runat="server" NavigateUrl='<%# DataBinder.Eval(Container.DataItem,"URL") %>' Target="_blank" ><%# DataBinder.Eval(Container.DataItem,"URL") %></asp:HyperLink>
</ItemTemplate>
<SeparatorTemplate>
<br><br>
</SeparatorTemplate>
</asp:Repeater>
-
Re: Formatted Text
The description container item is what should be receiving the text from the database which includes newlines.
-
Re: Formatted Text
I have no understanding of ASP technology I am afraid so I will be unable to help you there.
-
Re: Formatted Text
Does anyone else have an idea?