服务器标签格式不正确 - RegularExpressionValidator

Mac*_*Mac 0 c# regex asp.net server-tags

我正在尝试编写一个RegularExpressionValidator,它会检查以确保文本框中的条目是整数(不包含"."或",",只有"500"之类的整数值)

但我遇到过这个:

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: The server tag is not well formed.
Run Code Online (Sandbox Code Playgroud)

代码如下:

<asp:TextBox ID="Paymenttb" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID ="PaymentValidator" runat="server" ControlToValidate="Paymenttb" 
ErrorMessage="Payment must be of type Int (No "." or "," for example)." ValidationExpression="^\d+$">*</asp:RegularExpressionValidator>
Run Code Online (Sandbox Code Playgroud)

这有什么问题?我四处搜寻,找不到任何理由说明这种情况不好.

sin*_*800 5

ErrorMessage="Payment must be of type Int (No "." or "," for example)." 
Run Code Online (Sandbox Code Playgroud)

这部分.您在引用参数中有引号.

你可以通过使用外引号单引号来解决这个问题:

ErrorMessage='Payment must be of type Int (No "." or "," for example).'
Run Code Online (Sandbox Code Playgroud)

另一种解决方案:逃避报价html风格:

ErrorMessage="Payment must be of type Int (No &quot;.&quot; or &quot;,&quot; for example)." 
Run Code Online (Sandbox Code Playgroud)

"