在 ASP.net 中,我尝试将变量值设置为隐藏字段,但出现异常。
在第一个输出中,它是正确的。然后我把它放到隐藏字段中,失败了。
如何解决?
user name: <%= User.Identity.Name %> // output is correct
<form runat=Server>
<asp:HiddenField id="HiddenField1" value=<%= User.Identity.Name %> runat=Server />
</form>
错误
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Server tags cannot contain <% ... %> constructs.