Wednesday, March 21, 2012

Paragraph

I have a news content in a database stored using text data type. I wantto put it on an ASP.Net page in paragraphs, but I don`t
know how to do it, because the news content in the database doesn`thave paragraph. So if I put them on a page, they will become oneparagraph.
I`m using VB.NET for my ASP.Net. Is there anyone know how to solve this problem ?
Thanks a lot before.

that's because, when you added the line feeds into your text, when they went into the database, they were just that - line feeds...your web page, using HTML, doesn't recognize those line feeds, so you need to replace them with something that shows up correctly on a web page - -

so - replace the line feeds (vbcrlf) in the entire section of code with "<br>"
Something like:
Dim sData as string
sData=objDR("NewsContent")
sData=sData.Replace(vbcrlf, "<br>"


I don`t really understand how to do that. This is my code :
Public MyCon As New SqlConnection("server=127.0.0.1;uid=sa;pwd=password;database=userowndata")
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyCon.Open()
Dim kode As String = Request.QueryString("kode")
Dim MyComm As New SqlCommand("SELECT * FROM news WHERE newsId='" & kode & "'", MyCon)
Dim MyDr As SqlDataReader = MyComm.ExecuteReader()
If MyDr.Read Then
lblTitle.Text = MyDr("title")
lblNewsDate.Text = MyDr("newsDate")
lblSmallContent.Text = MyDr("smallContent")
lblContent.Text = MyDr("content")
End If
MyDr.Close()
End Sub
Would you mind to examine my code, and give me the right codes to make the news in paragraph ? I really appreciate your help.
Thank you very much.


Dim sData as string
sData=MyDr("content")
sData=sData.Replace(vbcrlf, "<br>"
lblContent.Text = sData
It`s not really working, the lines aren`t tidy. What should I do then ? Even some news, still doesn`t have paragraph.

0 comments:

Post a Comment