如何为链接按钮赋予颜色 [英] how to give color for link button
本文介绍了如何为链接按钮赋予颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我在asp.net的第一个项目。我使用转发器进行了数字分页
this is my first project in asp.net. I have done numeric paging using repeater
<asp:Repeater ID="Repeater1" runat="server">
<itemtemplate>
<asp:LinkButton ID="lnkPageno" OnClick="lnkPageno_Click" Text="<%#Container.DataItem %>"
runat="server">
</itemtemplate>
我试图动态更改点击数字的颜色(例如,1到10中的2)。我应用CSS,当前页面的颜色仍然没有改变。任何人都可以帮助我吗?
I tried to change the color of the clicked number (eg., 2 out of 1 to 10) dynamically. i applied CSS, still color of the current page not changed. Can anyone help me?
推荐答案
检查以下链接。
他们使用javaScript在点击时更改链接按钮颜色。
检查答案2。
参考 - 单击时更改链接按钮颜色,无后回或更新面板 [ ^ ]
Check following link.
They have used javaScript to change linkbutton color on click.
Check answer no2.
Refer - ASP.NET Change link button color when clicked without post-back or update panel[^]
<asp:linkbutton id="lnkPageno"
onclientclick="return Color(this);"
text="<%#Container.DataItem %>">
</asp:linkbutton>
现在的javaScript:
The javaScript now:
function Color(evt){
evt.style.Color = "your_Color";
}
假设这是HTML并且链接当前无处可去,您必须将href值更改为有效的URL:
Assuming this is the HTML and the link current goes nowhere, you have to change the href value to a valid URL:
<a href="#" id="mylink" style="color:blue;">My blue link</a>
请注意,我给了它一个id,这是为了让javascript转向它用不同的颜色标识这个标签。
Notice that I gave it an id, that''s for the javascript to turn it to different color and identify this tag.
window.onload = function() {
document.getElementById('mylink').onclick = function() {
this.style.color = 'green';
}
}
这篇关于如何为链接按钮赋予颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文