代码之家  ›  专栏  ›  技术社区  ›  Dave Mateer

轻松验证复选框列表

  •  0
  • Dave Mateer  · 技术社区  · 14 年前

    问题:未知的服务器标记“cc:ValidateableCheckBoxList”。

    namespace fmwebapp1.UserControls
    {
        [ValidationPropertyAttribute("ValidateableProperty")]
        public class ValidateableCheckBoxList : CheckBoxList
        {
            public string ValidateableProperty
            {
                get { return (this.Items.Cast<ListItem>().Where(i => i.Selected).Count() > 0) ? "something was selected" : ""; }
            }
        }
    }
    

     <%@ Register Namespace="fmwebapp1.UserControls" Assembly="ValidateableCheckBoxList" TagPrefix="cc" %>   
    <cc:ValidateableCheckBoxList runat="server" ID="cblFindTheSite">
                                            <asp:ListItem>The Press</asp:ListItem>
                                            <asp:ListItem>blah1</asp:ListItem>
                                            <asp:ListItem>blah2</asp:ListItem>
                                                                                    </asp:CheckBoxList>
                                        <div class="validators">
                                            <asp:RequiredFieldValidator runat="server" ID="rfvTest" ControlToValidate="cblFindTheSite" Text="Failed validation" ></asp:RequiredFieldValidator>
                                        </div>
    
    1 回复  |  直到 14 年前
        1
  •  0
  •   RPM1984    14 年前

    检查Web应用程序中引用的程序集是否与Register指令中的“assembly”属性匹配。