0

テキストボックスへのエントリが整数であることを確認する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.

コードは次のとおりです。

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

これの問題は何ですか?私は周りを検索しましたが、これがうまく形成されない理由を見つけることができません。

4

3 に答える 3

5
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)." 

「」

于 2012-02-08T14:52:52.567 に答える
0

あなたのErrorMessage属性は整形式ではありません:

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

属性値でをエスケープする必要があり"ます-それらを2倍にすることによってそれを行います:

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

または、一重引用符を使用して属性値を区切ります。

ErrorMessage='Payment must be of type Int (No "." or "," for example).'
于 2012-02-08T14:52:44.410 に答える
0

これを試して

<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> 
于 2012-02-08T14:58:36.247 に答える