zoukankan      html  css  js  c++  java
  • 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;
           }
        }
  • 相关阅读:
    联想IdeaPad品牌出炉 三款笔记本亮相
    [推荐]2008年必不可少的20个网络产品
    微软公开.NET Base Classes源代码
    [共享一下]Head.First.设计模式.中文版
    IT: 蓝牙十岁了
    祝贺“阿来之家”博客正式开通~
    NodeJS安全设计:好吃的草莓味糖果,只给好朋友小红
    NodeJS文件读取:感恩常在抓把糖果,愉悦客人
    NodeJS缓存机制:畅销货,就多囤一点呗
    安装pygame出现is not a supported wheel on this platform解决办法
  • 原文地址:https://www.cnblogs.com/ahjesus/p/1998646.html
Copyright © 2011-2022 走看看