use javascript to change the color for mouseover
-
after I get the id of the linkbutton (as follows), then how to change the backcolor of the button I do not know which function can be used. function LinkBtnMouseOver() { var LinkClientID = "<%=LinkButton1.ClientID%>"; var NewID = document.getElementById(LinkClientID); ? } thanks.
Why you are not putting the LnkButton inside
Div/Table
and change the backcolor of that on mouseover of linkbutton.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Why you are not putting the LnkButton inside
Div/Table
and change the backcolor of that on mouseover of linkbutton.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
thanks, I did not get you, anyway, above method is suggested by you (right?) can you help me further for this? for your new proposal, can you give me one example, how to do it?
-
after I get the id of the linkbutton (as follows), then how to change the backcolor of the button I do not know which function can be used. function LinkBtnMouseOver() { var LinkClientID = "<%=LinkButton1.ClientID%>"; var NewID = document.getElementById(LinkClientID); ? } thanks.
-
after I get the id of the linkbutton (as follows), then how to change the backcolor of the button I do not know which function can be used. function LinkBtnMouseOver() { var LinkClientID = "<%=LinkButton1.ClientID%>"; var NewID = document.getElementById(LinkClientID); ? } thanks.
-
oops my text came half !!! :-D and add this one to java script:
NewID.style.backgroundColor = 'yourcolor';
thanks, unfortunately, no .style is supported by NewID. it is strange that you can use .style?? I am using visual web developer 2008 express. oh, unbelievable, when I type NewID.style.backgroundColor ="Blue", it does work! but strange is that: when I type NewID. then all the functions within NewID should be automatically appear, but .style can not be found anyway. do you know the reason? a bug or sth else?
-
thanks, unfortunately, no .style is supported by NewID. it is strange that you can use .style?? I am using visual web developer 2008 express. oh, unbelievable, when I type NewID.style.backgroundColor ="Blue", it does work! but strange is that: when I type NewID. then all the functions within NewID should be automatically appear, but .style can not be found anyway. do you know the reason? a bug or sth else?
:laugh: yes i know it`s like this ;) i have visual studio enterprise , and it`s not supported very well here too !:mad: but i think that on express mode many of features are not working :suss: i think that just some stupid coder like me can Use these old "dhtml" commands ! but any how i love dhtml an i use it any where ;P
-
:laugh: yes i know it`s like this ;) i have visual studio enterprise , and it`s not supported very well here too !:mad: but i think that on express mode many of features are not working :suss: i think that just some stupid coder like me can Use these old "dhtml" commands ! but any how i love dhtml an i use it any where ;P
thanks, further question, as you know, I can solve this problem as follows, but I have many linkbuttons, should I write different funcitons for different buttons, because the button ID is used in the funcitons, how can I write one common function which can be used by all buttons by passing the ID or sth else? function LinkBtnMouseOver() { var LinkClientID = "<%=LinkButton1.ClientID%>"; var NewID = document.getElementById(LinkClientID); NewID.style.backgroundColor = "Blue"; } function LinkBtnMouseOut(obj) { var LinkClientID = "<%=LinkButton1.ClientID%>"; var NewID = document.getElementById(LinkClientID); NewID.style.backgroundColor = "Green"; }
-
thanks, further question, as you know, I can solve this problem as follows, but I have many linkbuttons, should I write different funcitons for different buttons, because the button ID is used in the funcitons, how can I write one common function which can be used by all buttons by passing the ID or sth else? function LinkBtnMouseOver() { var LinkClientID = "<%=LinkButton1.ClientID%>"; var NewID = document.getElementById(LinkClientID); NewID.style.backgroundColor = "Blue"; } function LinkBtnMouseOut(obj) { var LinkClientID = "<%=LinkButton1.ClientID%>"; var NewID = document.getElementById(LinkClientID); NewID.style.backgroundColor = "Green"; }
ex me because it`s late night here , and i must go to bed ;) you can use something like this :
link button
and change yur javascript to this mode :
function LinkBtnMouseOver(e) {
document.getElementById(e).style.backgroundColor = 'Blue';
}function LinkBtnMouseOut(e) {
document.getElementById(e).style.backgroundColor = 'Green';
}or maybe it works directly on your asp page totaly like this new one : :sigh:
<asp:LinkButton ID="LinkButton1" runat="server" onmouseover="this.style.backgroundColor = 'Blue';" onmouseout="this.style.backgroundColor = 'Green';">link button
hope that it works :rolleyes:
-
ex me because it`s late night here , and i must go to bed ;) you can use something like this :
link button
and change yur javascript to this mode :
function LinkBtnMouseOver(e) {
document.getElementById(e).style.backgroundColor = 'Blue';
}function LinkBtnMouseOut(e) {
document.getElementById(e).style.backgroundColor = 'Green';
}or maybe it works directly on your asp page totaly like this new one : :sigh:
<asp:LinkButton ID="LinkButton1" runat="server" onmouseover="this.style.backgroundColor = 'Blue';" onmouseout="this.style.backgroundColor = 'Green';">link button
hope that it works :rolleyes:
-
after I get the id of the linkbutton (as follows), then how to change the backcolor of the button I do not know which function can be used. function LinkBtnMouseOver() { var LinkClientID = "<%=LinkButton1.ClientID%>"; var NewID = document.getElementById(LinkClientID); ? } thanks.
Why do you need javascript when there is no need.
Javascript
is slower than actual CSS AFAIK. Just a simple fix for you. In Head section Add<style type="text/css"> .lnk { background-color:Green; } .lnk:hover { background-color:Aqua; } </style>
Now inside Form create these
<asp:LinkButton CssClass="lnk" runat="server" >This is link
</asp:LinkButton>Now see it should be working. Make appropriate alteration on the CSS. :rose::rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
thank you very much! I have rated 5!
-
Why do you need javascript when there is no need.
Javascript
is slower than actual CSS AFAIK. Just a simple fix for you. In Head section Add<style type="text/css"> .lnk { background-color:Green; } .lnk:hover { background-color:Aqua; } </style>
Now inside Form create these
<asp:LinkButton CssClass="lnk" runat="server" >This is link
</asp:LinkButton>Now see it should be working. Make appropriate alteration on the CSS. :rose::rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
have you tried by yourself? anyway, it does not work for my case, that's why I am looking for other methods.
-
have you tried by yourself? anyway, it does not work for my case, that's why I am looking for other methods.
Yes .. I did check myself. I have already replied to some other guy in this forum about this. If you need me to send you the web page which render this, I can do that.:rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.