簡體   English   中英

服務器標記格式不正確-RegularExpressionValidator

[英]The Server Tag is not well formed - RegularExpressionValidator

我正在嘗試編寫一個RegularExpressionValidator,以檢查以確保進入文本框的條目是Integer(不包含“。”或“,”,僅包含“ 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.

代碼如下:

<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>

這是什么問題? 我四處搜尋,找不到任何無法正常形成的原因。

ErrorMessage="Payment must be of type Int (No "." or "," for example)." 

這部分。 您帶引號的參數中有引號。

您可以通過使外部引號成為單引號來解決此問題:

ErrorMessage='Payment must be of type Int (No "." or "," for example).'

另一個解決方案:轉義html樣式的引用:

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

您的ErrorMessage屬性格式不正確:

ErrorMessage="Payment must be of type Int (No "." or "," for example)."

你需要躲避" ,在屬性值-做他們加倍:

ErrorMessage="Payment must be of type Int (No ""."" or "","" for example)."

或者,使用單引號分隔屬性值:

ErrorMessage='Payment must be of type Int (No "." or "," for example).'

嘗試這個

<asp:TextBox ID="Paymenttb" runat="server"></asp:TextBox>


<asp:RegularExpressionValidator ID ="RegularExpressionValidator1" runat="server" ControlToValidate="Paymenttb"  ToolTip="Payment must be of type Int (No '.' or ',' for example)." ValidationExpression="^\d+$">*</asp:RegularExpressionValidator> 

要么

<asp:RegularExpressionValidator ID ="PaymentValidator" runat="server" ControlToValidate="Paymenttb"  ErrorMessage="Payment must be of type Int (No '.' or ',' for example)." ValidationExpression="[0-9]"></asp:RegularExpressionValidator> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM