problem with tags

M

miladhatam

hi friends
i've built a page that should show first 150 chars of every of my
topics but when i wanted to do this work with SubString() it included
the tags of my field of my db and very bad viewing happend
i want to retrieve rendered text without any tag ...
please help me ...
 
J

Jonathan Wood

Sounds like there's a problem with your code, but you didn't include your
code, or any details about what you are doing beyond using SubString() so I
really don't see how anyone can help you.

Perhaps you should show, or at least describe, just what you are doing.

Beyond that, you can set a break point at look at the string being passed to
Substring and your arguments and you should be able to see why it returns
what it does.
 
M

Milosz Skalecki [MCAD]

Goo evening,

I think he's trying to trim text containing HTML content (which isn't
trivial).
 
J

Jonathan Wood

Perhaps, that's something I've done. It's just hard to help someone when
they don't show what they did.
 
M

miladhatam

:)
sorry my english language is not good
for eg :
in my record of field is this text
<b> hello world </b>
and i want to show only 5 first chars
i don't want the "<b>" tag be
i need my basic text without any style
that is the "hello"
thanks for your attention
 
M

marss

in my record of field is this text
<b> hello world </b>
and i want to show only 5 first chars
i don't want the "<b>" tag be
i need my basic text without any style
that is the "hello"

Remove tag by means of a regular expression.

Regex re = new Regex("<[^>]*>", RegexOptions.Multiline);
string pureText = re.Replace(originalString, "");

And then pureText.SubString(..

Regards
Mykola
http://marss.co.ua - Casual ideas for web development
 
M

Milosz Skalecki [MCAD]

Goo evening guys,

Having said it's not a trivial task i meant it's not trivial when trimming
text but persisting HTML. Mars' resolution will work only in most all of the
cases, but not if you trim the text at a html encoded character. This case is
easy to handle by making sure by checking if the ampersand is not included in
last 6 characters. Similar issue to this:
http://www.dcomments.net/ASP_.NET/message1516138.html

Regards
--
Milosz


marss said:
in my record of field is this text
<b> hello world </b>
and i want to show only 5 first chars
i don't want the "<b>" tag be
i need my basic text without any style
that is the "hello"

Remove tag by means of a regular expression.

Regex re = new Regex("<[^>]*>", RegexOptions.Multiline);
string pureText = re.Replace(originalString, "");

And then pureText.SubString(..

Regards
Mykola
http://marss.co.ua - Casual ideas for web development
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top