problem with tags

  • Thread starter Thread starter miladhatam
  • Start date Start date
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 ...
 
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.
 
Goo evening,

I think he's trying to trim text containing HTML content (which isn't
trivial).
 
Perhaps, that's something I've done. It's just hard to help someone when
they don't show what they did.
 
:)
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
 
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
 
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
 
Back
Top