打印本文 打印本文  关闭窗口 关闭窗口
APS + 中文教程(三)--服务器端控制(一)
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005/9/10 12:32:17
valid!";
            }
            else {
               lblOutput.Text = "Page is not valid! :-(";
            }
        }

        bool ServerValidate (object source, string value) {

            int num = Int32.FromString(value);
            
            if (num%2 == 0)
                return true;
            else
                return false;
        }
        
   </script>

</head>
<body>

<h3><font face="Verdana">CustomValidator Example</font></h3>

<form runat="server">

    <asp:Label id=lblOutput runat="server"
        Text="Enter an even number:"
        Font-Name="Verdana"
        Font-Size="10pt" /><br>

    <p>

    <asp:TextBox id=Text1 runat="server" />
    
    &nbsp;&nbsp;

    <asp:CustomValidator id="CustomValidator1" runat="server"
        ControlToValidate="Text1"
        OnServerValidationFunction="ServerValidate"
        Display="Static"
        Font-Name="verdana" Font-Size="10pt">
           Not an even number!
    </asp:CustomValidator>

    <p>

    <asp:Button text="Validate" onclick="ValidateBtn_OnClick" runat="server" />

</form>

</body>
</html>

上一页  [1] [2] 



打印本文 打印本文  关闭窗口 关闭窗口