By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,594 Members | 3,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,594 IT Pros & Developers. It's quick & easy.

How to get the text in html tag.like<div...><font...>Text</font></

P: n/a
hi, all
I know we can do this by some jscript. But is there a way to do it in
asp.net c# code?
In our project, users could sumit a piece of html code and I need to remove
all html tag out. What's the better way to do this?

Thanks and have a wonderful holiday!
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I think by default the framework throws an exception if you enter tags in an
input field (check out ValidateInput). But if you want to let them enter it,
on the back end you can either use htmlEncode to make it harmless, or
regex.replace to replace the tags with empty strings (try regexlib.com for
examples).

Bill

"Nicky" wrote:
hi, all
I know we can do this by some jscript. But is there a way to do it in
asp.net c# code?
In our project, users could sumit a piece of html code and I need to remove
all html tag out. What's the better way to do this?

Thanks and have a wonderful holiday!

Nov 19 '05 #2

P: n/a
Hello Nicky,

You can remove all tags with this regex:

string stripped = Regex.Replace(inputString, @"<(.|\n)*?>", String.Empty);

--
Matt Berther
http://www.mattberther.com
hi, all
I know we can do this by some jscript. But is there a way to do it in
asp.net c# code?
In our project, users could sumit a piece of html code and I need to
remove
all html tag out. What's the better way to do this?
Thanks and have a wonderful holiday!


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.