|
-
Jul 7th, 2003, 05:56 PM
#1
[*resolved]how can I detect and convert html tags to text?
lets say I have a textbox and the user enters some html tags in it. I want those to show up as text (well asp engine gives me an error if I enter html tags when submitting the value of the textbox). php had a simple function that converted all those to simple text. what should I do in asp.net?
Last edited by MrPolite; Jul 8th, 2003 at 05:29 PM.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 7th, 2003, 07:10 PM
#2
Addicted Member
If i understand you correctly the Server.HTMLEncode method should be able to help you out here - that help for a start?
Cheers
-
Jul 7th, 2003, 07:25 PM
#3
Originally posted by powdir
If i understand you correctly the Server.HTMLEncode method should be able to help you out here - that help for a start?
Cheers
hmm well I dont know how to use it. As soon as the page is submitted, before the click event for my button fires, I get the error message: A potentially dangerous Request.Form value was detected from the client (txtMessage="...dasdasdf <br>").
how can I fix this?
Here's all my page does: there is a textbox, and a button that shows teh content of the textbox in a label. Now if the user enters html tags in the textbox I get that error.... dunno how I can use the htmlencode function
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 7th, 2003, 08:05 PM
#4
Frenzied Member
Thats the new security in ASP.NET 1.1. To bypass it just put ValidateRequest="false" in the @Page attribute of the page that is is throwing the exception.
-
Jul 7th, 2003, 08:12 PM
#5
Addicted Member
...something like
Code:
dim str as string
str = Server.HTMLEncode(MyTextBox.text)
lets say your textbox (MyTextBox) has contains tags - which yours does - the above function will apply encoding to the contents, preventing malicious upload of HTML.
So....
Code:
dim str as string
str = Server.HTMLEncode("<P>") 'paragraph tag will output as <P>
likewise Server.HTMLDecode does the opposite
That help?
Cheers
-
Jul 7th, 2003, 08:53 PM
#6
Originally posted by powdir
...something like
Code:
dim str as string
str = Server.HTMLEncode(MyTextBox.text)
lets say your textbox (MyTextBox) has contains tags - which yours does - the above function will apply encoding to the contents, preventing malicious upload of HTML.
So....
Code:
dim str as string
str = Server.HTMLEncode("<P>") 'paragraph tag will output as <P>
likewise Server.HTMLDecode does the opposite
That help?
Cheers
umm well ok I'm sure there is nothign wrong with that line of code, but the problem is that the compiler never actually runs the code, it gives me the error before it would fire any events.
just try this, put a textbox and a button on a project. run it, and type a <br> in the textbox. when you press the button and the textbox's contents are submitted you'll get an error
I'm sure there is a simple solution to this, I just dunno how to get around it because I'm new to asp 
so I'm talking about 2 problems in this post
1- how to convert those tags to plain text -> you answered me, htmlEncode(), thanks 
2- how to aviod that error -> still dunno
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 7th, 2003, 09:10 PM
#7
Frenzied Member
Originally posted by MrPolite
umm well ok I'm sure there is nothign wrong with that line of code, but the problem is that the compiler never actually runs the code, it gives me the error before it would fire any events.
just try this, put a textbox and a button on a project. run it, and type a <br> in the textbox. when you press the button and the textbox's contents are submitted you'll get an error
I'm sure there is a simple solution to this, I just dunno how to get around it because I'm new to asp 
so I'm talking about 2 problems in this post
1- how to convert those tags to plain text -> you answered me, htmlEncode(), thanks 
2- how to aviod that error -> still dunno
Dude apparently you did'nt read my post.
-
Jul 8th, 2003, 12:08 AM
#8
PowerPoster
As DevGrp said:
That is your problem. I had to do it to this page of mine to get it to work:
http://www.variantx.com/Main/DevTools/HTMLEncoder.aspx
-
Jul 8th, 2003, 05:27 PM
#9
Originally posted by DevGrp
Dude apparently you did'nt read my post.
lol sorry I wasnt ignoreing you or anything, I swear I didnt even see your post my bad, gotto open my eyes better. thanks for the answer 
edit: what other things does that ValidateRequest do?
Last edited by MrPolite; Jul 8th, 2003 at 05:45 PM.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jul 8th, 2003, 11:07 PM
#10
Frenzied Member
I dont think it does anything else.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|