Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I implemented a DataList where the EditItemTemplate contains a textbox with user input. the string written in the textbox is not showed if not in editmode. When the string contains script injection like alert the control acts funny .... not...

When I click the editmode button the datalist shows the text as expected because the textbox control can handle the script injection.
BUT when I click the cancel editmode the page goes to yellow screen of death with "A potentially dangerous Request. Form value was detected from the client" pointing at the textbox with the script injection.

The code running when cancelbutton is pressed:
MyDataList.EditItemIndex = (int)e.Item.ItemIndex;
MyMessageDataList.DataSource = myList;
MyMessageDataList.DataBind();


Does anyone know why this happen?

The "script injection"-text is not showed in a label or something.
Posted
Updated 3-Feb-11 15:02pm
v2

You're going to have to set ValidateRequest to false in web.config if you want to suppress this behaviour. be aware though, that doing this opens your site up to script injection and therefore possible XSS vulnerabilities. you'll have to handle all the user input yourself.
 
Share this answer
 
Comments
fjdiewornncalwe 3-Feb-11 21:42pm    
OP's comment moved from answer: Yea i found that one and didnt want to do that.
it must be another way.
btw. it collapses before it even goes to page_load.
i was wondering if the datalist does something with the string that makes it goes boom?
it seems that this bug is a "work as intended"-bug.
ValidateRequest seems to validate every text and throws that error just in case...
which seems to me, makes the validaterequest="true" unusable in real applications where that behavior realy itn't wanted.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900