`
pavel
  • 浏览: 915767 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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;
       }
    }

//明白了吗。。这是一个用来判断两次密码输入是否一致的函数

分享到:
评论

相关推荐

    Sirenix.OdinInspector.Attributes.dll

    Sirenix.OdinInspector.Attributes.dll

    ASP.NET程序中常用的三十三种代码

    1. 打开新的窗口并传送参数: ...Button1.Attributes.Add("onclick","return confirm(’确认?’)"); button.attributes.add("onclick","if(confirm(’are you sure...?’)){return true;}else{return false;}")

    showModalDialog和showModelessDialog的用法

    Button1.Attributes.Add("onclick","window.showModalDialog('../Dialog/DialogForm.aspx',window)"); 步骤二:父页面页面脚本函数。 function setAttaches(strboxValue) { document.getElementById("lblSign")....

    org-gephi-data-attributes-api

    org-gephi-data-attributes-api可视化软件gephi的插件,nbm格式,

    ASP.NET常用的三十三种实用代码

    Button1.Attributes.Add("onclick","return confirm(’确认?’)"); button.attributes.add("onclick","if(confirm(’are you sure...?’)){return true;}else{return false;}") 3.删除表格选定记录 int intEmpID = ...

    datagridview 表头

    datagridview 表头 case DataControlRowType.Header: ... //tcHeader[1].Attributes.Add("bgcolor", "Red"); tcHeader[1].Attributes.Add("colspan", "6"); //跨Column tcHeader[1].Text = "全部信息&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;";

    onClientclick 失效问题.rar

    今天在开发过程中发现一个问题,在asp:Button按钮属性Enabled="false"时,也就是按钮变类...解决的方法是在后台代码的 Page_Load(object sender, EventArgs e)里添加Button1.Attributes.Add("onclick", "showAlert()");

    ASP.NET常用代码

    Button1.Attributes.Add("onclick","return confirm('确认?')"); button.attributes.add("onclick","if(confirm('are you sure...?')){return true;}else{return false;}") 3.删除表格选定记录 int intEmpID = (int...

    Backbone.Attributes:给任何对象 Backbone getter 和 setter

    Backbone.Attributes 是一个很小的(约 400 字节缩小/gz)插件,用于提供任何对象 Backbone.Model getter/setter 方法。 有时模型太重,或者您不需要 Backbone 模型提供的完整同步/收集方法。 var view = new ...

    网页设计人员必看:JavaScript使用技巧精萃

    BtnDel.Attributes.Add("onclick","return confirm('"+"确认删除?"+"')"); 2. linktempDelete.Attributes["onclick"]="javascript:return confirm('"+"确认删除?"+"');"; 3. private void grdProject_...

    。NET经典技术

     Button1.Attributes.Add("onclick","return confirm('确认?')"); button.attributes.add("onclick","if(confirm('are you sure...?')){return true;}else{return false;}")  接收参数:  string a = Request....

    一个对XmlDocument的DocumentElement 以及其属性Attributes进行访问的类库函数

    一个对XmlDocument的DocumentElement 以及其属性Attributes进行访问的类库函数。

    C#的HTML代码解析类

    (tag.Attributes.ContainsKey("class") && tag.Attributes["class"] == "result-item")) continue; if (!parser.ParseNext("a", out tag)) continue; if (!tag.Attributes.ContainsKey("href")) continue; list....

    ASP.Net开发常见的一些问题总结

    1. 打开新的窗口并传送参数: 传送参数: response.write(“[removed]window.open(‘*.aspx?...Button1.Attributes.Add(“onclick”,”return confirm&#40;‘确认?’&#41;”);button.attributes.a

    Nhibernate一对多级联保存_双向映射

    Nhibernate拒绝配置文件(NHibernate.Mapping.Attributes的使用)

    C#后台调用前台javascript的五种方法小结

    在网上找了找,发现有三种方法可以访问到前台代码: 第一种,OnClientClick (vs2003不... 第二种,Button1.Attributes.Add(“onclick”, “return Client_Click()”); “Client_Click() “是一个前台方法,可以替换成一

    commons-attributes-2.2.zip

    commons-attributes-2.2.zipcommons-attributes-2.2.zipcommons-attributes-2.2.zipcommons-attributes-2.2.zipcommons-attributes-2.2.zipcommons-attributes-2.2.zip

    gridview 简单代码

    e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); ...

Global site tag (gtag.js) - Google Analytics