2012-02-08 17 views
0

テキストボックスへのエントリがIntegerであることを確認するRegularExpressionValidatorを書き込もうとしています(「。」または「、」は含まれていません。 )サーバタグがうまく構成されていない - RegularExpressionValidator

しかし、私はこの遭遇した次のようなコードがある

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> 

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

+1

あなたのエラーメッセージは、私はそれを見ていないと信じてすることはできません – Shai

答えて

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

"

+0

許可されていない '" '含まれています!どのような素人の間違い。どうもありがとう。答えとしてマークします。私はちょうどコードが長すぎると思っています。 – Mac

0

あなた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).' 
0

は試してみてください。この

OR

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