How do I allow HTML in just one textbox?

A

Alan Silver

Hello,

I am writing a web form where the user is allowed to enter HTML into one
of the textboxes. This of course generates the "potentially dangerous"
server error.

Now I know I can switch off the validation for the page by using the
validateRequest page directive, but this switches it off for *all*
controls on the page. I have loads and loads of them, but only want to
allow HTML in this one control. I really don't want to have to write
validation for every other control.

Is there a way of allowing HTML in just one control? TIA
 
G

Guest

Hi Alan,

One quick and dirty workaround would be to set validation group property for
all other controls in the page and then assign the same validation group
property value to the submit button. But do remember to leave it blank for
the control you dont want to validate...

This will ensure that the validation wil fired for all controls whose
validation property is set (and matches with the validation group value of
the submit button)..

There are other ways... but bit messy ... and complicated. ...

Derive a user control from the control we want to subclass, then in the
validate method do something so it doesnt validate the data.

I suggest you follow the first method (in case you dont find a better sol)

HTH,

Need any help, do post a msg back..


Happy Coding
 
A

Alan Silver

Hello,

Thanks for the reply. The first method you suggest sounds the easiest,
but I'm not really clear what you mean. I'm pretty new at this and still
finding my way around.

Please could you explain it a bit more, preferably with some simple code
so I can see what you mean. Thanks very much.

Alan
 
S

Scott Allen

Two problems: ASP.NET 1.1 doesn't have a 'validation group' out of the
box, some third party libraries add this feature. Plus, request
validation happe
 
S

Scott Allen

Opps, I think I posted a little too soon.

1) ASP.NET 1.x doesn't have validation groups.

2) The request validation is unrelated to validation controls. Request
validation happens before execution reaches the code behind the page
or any of the controls on the page.
 
A

Alan Silver

Opps, I think I posted a little too soon.
1) ASP.NET 1.x doesn't have validation groups.

2) The request validation is unrelated to validation controls. Request
validation happens before execution reaches the code behind the page
or any of the controls on the page.

Does this mean that this will or won't be possible in ASP.NET 2.0? Your
first point makes it sound like it will (but not in 1.1), but your
second point makes it sound like it can't be done in any version due to
the way ASP.NET works.

Please clarify. Thanks
 
S

Scott Allen

Yes - sorry about the first post it was sent by my cat who has a
fondness for the "Send" keyboard shortcut...

It will not be possible in 2.0 either, unless there is a change coming
in beta 2.

To try to clarify: validation groups are not available in the current
version of ASP.NET, but even if they were they would not help with
this scenario.
 
A

Alan Silver

Yes - sorry about the first post it was sent by my cat who has a
fondness for the "Send" keyboard shortcut...

I have a small daughter like that ;-)
It will not be possible in 2.0 either, unless there is a change coming
in beta 2.

To try to clarify: validation groups are not available in the current
version of ASP.NET, but even if they were they would not help with
this scenario.

OK, thanks. I'll have a go at the encoding that someone else suggested.
That seems simple enough (famous last words...)

Ta ra
 

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

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,282
Latest member
RoseannaBa

Latest Threads

Top