读书人

CustomValidator OnServerValidate时不

发布时间: 2012-01-26 19:40:46 作者: rapoo

CustomValidator OnServerValidate时不时 不进事件,丫的 谁有高见!小弟跪求。
[align=left]example:

HTML code
<asp:TextBox ID="_defineTextBox" runat="server"  Width="40px" />                <asp:CustomValidator ID="_defineTextValidator" runat="server" ControlToValidate="_defineTextBox"                 OnServerValidate="Define_OnServerValidate"  Display="Dynamic"  ErrorMessage="Must be between 0.00% and 100.00%." ForeColor="Red"                  SetFocusOnError="True" ToolTip="0.00%-100.00%" >*</asp:CustomValidator>


C# code
protected void Define_OnServerValidate(object source, ServerValidateEventArgs args)        {            bool valid = true;            decimal output = -1.0M;            if (!string.IsNullOrWhiteSpace(args.Value))            {                var amount = args.Value.Replace(CurrencyTye, "");                var value = decimal.TryParse(amount, out output) ? output : -1.0M;                if (value < 0M || value > 100.00M)                    valid = false;                else                    valid= true;            }            args.IsValid = valid;        }
[/align][align=left][/align]

[解决办法]
fuck u too!

读书人网 >.NET

热点推荐