zoukankan      html  css  js  c++  java
  • 自定义服务器控件 继承不到父类/基类的 SupportsEventValidation 特性. 不及格的程序员

    作者:不及格的程序员-八神


    MSDN 根本没有说它不可以继承, 事实上它真是不能继承.

    在SupportsEventValidationAttribute类的源码中可以看到注释
    Note that this attribute does not inherit from the base class, since derived classes may not be able to validate properly.

    我更愿意看到比较明确的声明,例如:
    [AttributeUsageAttribute(AttributeTargets.Class, Inherited = false, AllowMultiple = false)],而它没有这样声明.


    看看可序列化特性的声明,明确了它不能继承,所以我们在写要序列化类时必须带有该特性的声明.

    [AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Delegate, Inherited = false)]
    public
    sealed class SerializableAttribute : Attribute 



    这个属性是ASP.NET 2.0新增的 是为了验证用户控件回发的数据有效性 比如下拉列表盒,本身提供1到31天的选择,但是客户端修改了数据 提交了一个32的值,那么这时ASP.NET框架就会抛出异常,说提交数据非法. 有很多控件都会作这样的验证,如:Dropdownlist checkbox... 开发用户自定义控件,如果要验证数据的安全性,可以参考一下.

  • 相关阅读:
    加密的PDF文件怎么查看
    SQL Server数据库中怎么加密数据
    虚拟磁盘也加密
    怎么用密码保护您的文件夹
    如何用cmd命令加密文件夹
    快压轻松创建加密压缩包
    GPS学习的一些链接
    【最新软件预告】邮件群发器Console版
    第六格很酷的滚动活动会员条
    邀请您加入移动开发专家联盟
  • 原文地址:https://www.cnblogs.com/ioriwellings/p/1566946.html
Copyright © 2011-2022 走看看