• Attributes.Add用途与用法


    Attributes.Add("javascript事件","javascript语句");
    
    如:
    
    this.TextBox1.Attributes.add("onblue", "window.Label1.style.backgroundColor='#000000';");
    
    this.TextBox1.Attributes.Add("onblur","this.style.display='none'");
    
    javascript事件:
    
    onClick     鼠标点击事件,多用在某个对象控制的范围内的鼠标点击
    
    onDblClick    鼠标双击事件
    
    onMouseDown    鼠标上的按钮被按下了
    
    onMouseUp    鼠标按下后,松开时激发的事件
    
    onMouseOver 当鼠标移动到某对象范围的上方时触发的事件
    
    onMouseMove    鼠标移动时触发的事件
    
    onMouseOut 当鼠标离开某对象范围时触发的事件
    
    onKeyPress    当键盘上的某个键被按下并且释放时触发的事件.[注意:页面内必须有被聚焦的对象]
    
    onKeyDown    当键盘上某个按键被按下时触发的事件[注意:页面内必须有被聚焦的对象]
    
    onKeyUp   当键盘上某个按键被按放开时触发的事件[注意:页面内必须有被聚焦的对象]
    
    Attributes.Add添加多了之后会影响一定速度,Attributes和Attributes.CssStyle被自动保存到ViewState中后,除了ViewState体积急增后,PostBack时Load ViewState的负担也同时增大了。
    
     在下面的事件中添加,如下形式:
    protected override void Render(HtmlTextWriter output)
    {
        this.Attributes["abc"] = "123";
        this.Attributes.CssStyle["abc-style"] = "123-style";
        output.Write(Text);
    }
      就不会再将Attributes和Attributes.CssStyle保存到ViewState中
    
    引自:http://hi.baidu.com/sbdnpgk/blog/item/617ddb1a8b0de1128618bfbc.html
    
    Button1.Attributes.Add()方法小结 
    //首先要在PageLoad()事件中注册属性
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Button1.Attributes.Add("onclick", "return checkSame()");//为Button1添加onclick()事件 ,Button为服务器控件
            }//注意:checkSame()这是一个写在aspx面页的js函数,必须有返回值,为:true 或 false
        }
    
    //接着写Button1的onclick事件,如果刚才的checkSame()返回为true则招行下面的事件,否则不执行 
    
        protected void Button1_Click(object sender, ImageClickEventArgs e)
        {
            SqlParameter[] Params = new SqlParameter[2];
            Params[0] = dbs.MakeInParams("@uid", SqlDbType.VarChar, 10, Session["Uid"].ToString());
            Params[1] = dbs.MakeOutParms("@Upwd", SqlDbType.VarChar, 10);
            if (dbs.ExecuteNonQuery(CommandType.StoredProcedure, "selectPwd", Params) > 0)
            {
                string userPwd = Params[1].Value.ToString();
                if (userPwd != this.old_pwd.Text)
                {
                    Response.Write("<script>alert('原始密码错误!')</script>");
                }
                else
                {
                   
                }
            }
            else 
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('操作失败!')</script>");
            }
    
        }
    
    //呵呵。。再写一个js试例吧
          function checkSame()
        {
          var Obj1=document.getElementById ("new_pwd").value;
          var Obj2=document.getElementById ("re_new_pwd").value;
          
          if(Obj1!=Obj2)
           {
              alert("两次密码输入不一致!");
              document.getElementById("new_pwd").focus();
              return false;
           }
           else
           {
             return true;
           }
        }
  • 相关阅读:
    hdu 5475(打破固定思维OR线段树)
    hdu 2521 反素数(打表)
    hdu 4540(dp)
    hdu 4535(排列组合之错排公式)
    hdu 4530(数学)
    hdu 4528(搜索好题)
    hdu 4522(图论,构图)
    kalinux 换源
    用python进行wifi密码生成
    hashcat 中文文档
  • 原文地址:https://www.cnblogs.com/asdyzh/p/9757614.html
Copyright © 2020-2023  润新知