简体   繁体   中英

How to add attribute when onclick event in asp.net

Hi how can i add attribute into a button when button is clicked?

this is the attribute dojotype="dijit.form.Button"

void ButtonLogin_OnClick(object sender, EventArgs e)
{
 // the add attribute
}

this is my button

<button id="ButtonLogin" runat="server" onServerClick="ButtonLogin_OnClick"   jsid="ButtonLogin" style="float: right;
                            padding: 5px 15px 0px 0px;">
                           Login</button>

ButtonLogin_OnClick里面做

this.ButtonLogin.Attributes.Add("dojotype", "dijit.form.Button");

You can do it by JQUERY. I'm adding attribute to "a" tag:

     <a href="#" id="btnAttrib">Add Attrib</a>
     <script type="text/javascript">
            $("#btnAttrib").click(function () {
                $("#btnAttrib").attr("rel", "nofollow");                  
             })
     </script>

I think you change it to:

     <button id="ButtonLogin" runat="server" onServerClick="ButtonLogin_OnClick" jsid="ButtonLogin" style="float: right;padding: 5px 15px 0px 0px;">Login</button>

     <script type="text/javascript">
            $("#ButtonLogin").click(function () {
                $("#ButtonLogin").attr("dojotype", "dijit.form.Button");                  
             })
     </script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM