How to change button bordersytle ?

Last post 05-09-2008 8:21 AM by dinesh_sp. 6 replies.

Sort Posts:

  • How to change button bordersytle ?

    05-09-2008, 6:20 AM
    • Loading...
    • itman21c
    • Joined on 02-22-2008, 7:16 AM
    • Posts 22

    Hi.

    I am now making some code which is to change button borderstyle when mouse over or out.

    I made code following as.

     btnAttend.Attributes.Add("onmouseover", "this.style.borderstyle='solid'")
     btnAttend.Attributes.Add("onmouseout", "this.style.BorderStyle='none'")

    But nothing changed. what do i have problem ?

    I tried to change button backcolor and it was ok.

  • Re: How to change button bordersytle ?

    05-09-2008, 6:45 AM
    • Loading...
    • sreejukg
    • Joined on 10-31-2004, 7:33 AM
    • Posts 450

     you write some css class one with border and one without border. now change the class of the btn on mouse over

    btnAttend.Attributes.Add("onmouseover", "this.className='myclass'"); 

    The real voyage of discovery consists not in making new landscapes, but in having new eyes
  • Re: How to change button bordersytle ?

    05-09-2008, 7:05 AM
    • Loading...
    • jagan.unique
    • Joined on 02-08-2008, 9:42 AM
    • Hyderabad, India
    • Posts 129

    itman21c:

    I made code following as.

     btnAttend.Attributes.Add("onmouseover", "this.style.borderstyle='solid'")
     btnAttend.Attributes.Add("onmouseout", "this.style.BorderStyle='none'")

    But nothing changed. what do i have problem ?

    I tried to change button backcolor and it was ok.

     

     

    Actually you need to set the borderwidth for  btnAttend. try to set the borderwidth to 1px or more

     Ex.

    <asp:Button ID="Button2" runat="server" Text="Button" BorderWidth="1px" onmouseover="this.style.borderStyle ='none';" onmouseout="this.style.borderStyle ='solid';"/> 

  • Re: How to change button bordersytle ?

    05-09-2008, 7:27 AM
    • Loading...
    • itman21c
    • Joined on 02-22-2008, 7:16 AM
    • Posts 22

    Hi.

    I tried your code. But following warning happened.

    Warning 1 Validation (ASP.Net): Attribute 'onmouseover' is not a valid attribute of element 'Button'. D:\test\test.aspx 13 22.

     

  • Re: How to change button bordersytle ?

    05-09-2008, 7:49 AM
    • Loading...
    • jagan.unique
    • Joined on 02-08-2008, 9:42 AM
    • Hyderabad, India
    • Posts 129

     

    The above posted code is working for me.. and i am not sure why you are getting this error..

    below is the tested code which is also working for me..

    <asp:Button ID="Button2" runat="server" Text="Button" BorderWidth="1px" />
     

    Page_Load event

            Button2.Attributes.Add("onmouseover", "this.style.borderStyle ='none';")
            Button2.Attributes.Add("onmouseout", "this.style.borderStyle ='solid';")

     

    Check out this link. may be helpful to you..

    http://www.velocityreviews.com/forums/t118385-how-to-do-onmouseoveronmouseout-events-on-aspnet-button.html 

     

  • Re: How to change button bordersytle ?

    05-09-2008, 7:59 AM
    • Loading...
    • KashifB
    • Joined on 07-26-2007, 1:41 PM
    • Posts 139

    A few things you can do to check why it's not working:

    1. Look at the rendered HTML source, do the onmouseover and onmouseout events appear in the input button.
    2. Check your browsers JavaScript support is turned on.
    3. Check there are no JavaScript errors.
    4. this.style.borderStyle is NOT the same as this.style.BorderStyle, javascript is case sensetive

    If there's a javascript error, post it here.

  • Re: How to change button bordersytle ?

    05-09-2008, 8:21 AM
    • Loading...
    • dinesh_sp
    • Joined on 12-03-2007, 5:41 AM
    • Melbourne
    • Posts 313

    This is tested on Mozilla works fine, but doesnt work on IE. Its not code,its browser ISSUE. 

    <asp:Button ID="Button1" runat="server" Text="Button" onmouseover="this.style.borderStyle='solid';" onmouseout="this.style.borderStyle='none';" /><br />
            <input id="mybeuton" type="button" runat="server" value="Dinesh" onmouseover="this.style.borderStyle='solid';" onmousedown="this.style.borderStyle='none';" />

     

    Hope this helps. 

Page 1 of 1 (7 items)