I have a series of controls on an ASP page. Some are inside an UpdatePanel and some are not.
If I put an XML tag in one of the text boxes (eg, "<foo>
") then all the controls within the UpdatePanel don't work. As soon as the tags are 开发者_运维百科removed, everything is fine.
My 'submit' button is in the UpdatePanel and the breakpoint on btnSubmit_Click is only hit when there aren't tags in the text boxes.
I'm a long-time C# dev but quite new to ASP.NET so might be missing something obvious... this just isn't the behaviour I expect.
If you were to take the UpdatePanel off the page, you'd find that the postback was causing an error because .NET thinks that "<foo>" is a potentially dangerous bit of data to accept at the server. See this question on StackOverflow. You don't see the error because the error page HTML is being returned to the UpdatePanel's ajax call rather than direct to you browser, and the UpdatePanel doesn't know what to do with it.
You can turn off the checking by adding
ValidateRequest="false"
to the <@Page ... > directive at the top of your aspx file. Or you can modify the web.config to get the same effect right across your web app.
You can't put markup in a textarea. You must HTML-escape any markup characters inside textarea just as you must with any other element.
<textarea><foo> & <bar></textarea>
Although in practice browsers will usually work out what you mean and show any <
characters as-is, it's still invalid HTML and non-well-formed XML (presumably this is also the root of your issue in ASP.NET, though without specific code it's difficult to tell).
精彩评论