我试图找出可以使用 HtmlAttributeEncode 的上下文 -
我尝试了简单的“你好!” 警报脚本被设置为控制属性,所以我可以看到 HtmlAttributeEncode 正在运行 - 但看不到我可以在哪里使用 HtmlAttributeEncode 而不是 HtmlEncode。
所以,例如,我有
- a textbox for user input
//txtuserInput.Text = <script>alert(document.cookie);</script>
- an anchor control to show user input being set as one of its attribute value
In codebehind tried with -
myanchorTag.InnerText = txtuserInput.Text
or
myanchorTag.Id = txtuserInput.Text
但是我看不到这个脚本正在运行:-(
我已经尝试过 TextBox.Text 属性,但为此我可以使用 HtmlEncode。
任何人都可以请指导。
谢谢!