Hi,
I have some data which is stored in my MySQL database as TEXT. when the
data is entered in, it has some carriage returns in it, and this can be
seen when querying the data using MySQL Query Browser.
I want to then display this text within <p> tags when requested from
the database. However, the test is formatted without the carriage
returns.
Is there a simple bit of code in which i can use to display the text
complete with its carriage returns, or do i have to have a bit of messy
code which will replace all the carriage returns with &vbCrLF; ? 8 2195
You need to replace the CR's with <P> or <BR> 's in order to translate them
to HTML actionable code tags.
Use a RegEx to do this.
Regards Mr Newbie.
"TheDude5B" <ti*******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com... Hi,
I have some data which is stored in my MySQL database as TEXT. when the data is entered in, it has some carriage returns in it, and this can be seen when querying the data using MySQL Query Browser.
I want to then display this text within <p> tags when requested from the database. However, the test is formatted without the carriage returns.
Is there a simple bit of code in which i can use to display the text complete with its carriage returns, or do i have to have a bit of messy code which will replace all the carriage returns with &vbCrLF; ?
I would think you would have to replace the carriage returns with <br>'s.
Dim TestString As String = "Shopping List"
' Returns "Shipping List".
Dim aString As String = Replace(TestString, "o", "i")
Greg
"TheDude5B" <ti*******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com... Hi,
I have some data which is stored in my MySQL database as TEXT. when the data is entered in, it has some carriage returns in it, and this can be seen when querying the data using MySQL Query Browser.
I want to then display this text within <p> tags when requested from the database. However, the test is formatted without the carriage returns.
Is there a simple bit of code in which i can use to display the text complete with its carriage returns, or do i have to have a bit of messy code which will replace all the carriage returns with &vbCrLF; ?
I have used
Replace(post.Text, vbCrLf, "<br />")
and everything is working now, however, this is good for displaying my
text within the <p> tags. but when i view the text within a textbox,
for example when i want to edit the text, it shows up the <br /> tags
Only do the replace when displaying the text in a label. Should give some
thought to using Server.HtmlEncode too.
Replace(Server.HtmlEncode(post.Text), vbCrLf, "<br />")
"TheDude5B" <ti*******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... I have used Replace(post.Text, vbCrLf, "<br />")
and everything is working now, however, this is good for displaying my text within the <p> tags. but when i view the text within a textbox, for example when i want to edit the text, it shows up the <br /> tags
ok i will not replace the vbcrlf when adding it to the database.
however i am unsure as to apply the replace code with my asp:repeater
controls.
i have the code for the line, which i am wanting to use the replace in,
as
<td colspan="2"
class="bordersides"><p><%#Container.DataItem("post _text")%></p></td>
how would i apply Replace( ,vbCrLf,"<br />") with this line
of code?
i have got it now thanks.
used the code
<%#( DataBinder.Eval(Container.DataItem, "post_text")).Replace(vbCrLf,
"<br/>")%>
and this has worked.
Thanks for your Help Greg
Another method would be to write a protected helper function in your code
behind.
something like this:
<%# MyHelperFunction(DataBinder.Eval(Container.DataIte m, "post_text")))%>
Protected Function MyHelperFunction(ByVal value As Object) As String
If value Is DBNull.Value Then
Return ""
Else
Return value.ToString.Replace(vbCrLf,"<br/>")
End If
End Function
I find this kind of code necessary to protected myself from NULL values
coming back from db.
Greg
"TheDude5B" <ti*******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... i have got it now thanks.
used the code
<%#( DataBinder.Eval(Container.DataItem, "post_text")).Replace(vbCrLf, "<br/>")%>
and this has worked.
Thanks for your Help Greg
Instead of doing a replace, a css attribute exists that you can use to
format the text automatically:
<div style="white-space: pre-line;">
Text goes here
</div>
Lookup the "white-space" css attribute for more info.
Best of luck,
Matt Furnari This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Les Juby |
last post by:
Can someone please help with a suggestion as to how I can keep the
formatting (carriage returns) that the user enters into a memo field
and then display that later.
I figured I might be able to...
|
by: eagleofjade |
last post by:
I am trying to import data from a Word document into an Access table
with VBA.
The Word document is a form which has various fields. One of the fields
is a field for notes. In some cases, this...
|
by: Nimmy |
last post by:
Hi,
I have a data file and I want to remove Carriage returns. Any one has any C
code/program which does this? I am working on Windows XP machine.....I don't
have access to UNIX machine. But I...
|
by: Matt Mercer |
last post by:
Hi all,
I am having a frustration problem, and I have read about 25 newsgroup
postings that do not have a satisfying answer :)
The problem appears to be common where carriage returns are lost...
|
by: mattrapoport |
last post by:
I have a page with a div on it. The div displays a user comment. When
the user logs into this page, their current comment is pulled from a db
and displayed in the div. The user can edit the...
|
by: GregBeagle |
last post by:
Windows XP
I have a simple form from which I want to generate an email with the contents of the form. I use carriage returns to format the content for readability.
When I test it on my computer...
|
by: markus.shure |
last post by:
Hi,
I'm noticed a problem testing a JAX-WS client with a WSE server. The
JAX-WS client adds carriage returns to a SOAP header element that is
signed. This causes the WSE server to raise an...
|
by: evenlater |
last post by:
My db allows the user to send email via CDO. The body of the email is
determined in code. I have built an email form with To, CC and Subject
lines and a large text box for the body of the message...
|
by: jollyroger |
last post by:
I have searched the web forums, and can't seem to find an answer to this particular problem I have.
In an excel sheet, cells in one column have formatted text in the "wrapped" cells. For many of...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |