单击没有后退或更新面板时的ASP.NET更改链接按钮颜色 [英] ASP.NET Change link button color when clicked without post-back or update panel

查看:81
本文介绍了单击没有后退或更新面板时的ASP.NET更改链接按钮颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net页面上,我有一个链接"按钮列表:

in an asp.net page I have a list of Link buttons:

<asp:LinkButton ID="LinkButton1" runat="server" OnClick="Link_Click">Link 1</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" OnClick="Link_Click">Link 2</asp:LinkButton>
<asp:LinkButton ID="LinkButton5" runat="server" OnClick="Link_Click">Link 3</asp:LinkButton>

我将它们用作网站上更新面板的触发器.当用户单击链接时,控件就会加载到页面上.

I am using them as triggers for an update panel on the site. When a user clicks on a link a control gets loaded on the page.

这是我想要的:

当用户单击某个链接时,该链接的颜色会更改,以便我们知道最后按下哪个链接.

Whne the user clicks on a link the color of that link change so we can know which link was pressed last.

我希望没有回发或更新面板.那么有没有办法通过javascript做到这一点?或其他解决方案?

I would like to do this without post-back or update panels. So is there a way to do this via javascript? or other solutions?

谢谢您的帮助

推荐答案

JAVASCRIPT:

JAVASCRIPT:

<script>
    function changeColor(e) {
        e.style.color = "red";
        return false;
    }
</script>

HTML:

<asp:LinkButton ID="LinkButton1" OnClientClick="return changeColor(this);" runat="server">LinkButton</asp:LinkButton>

祝你好运!

这篇关于单击没有后退或更新面板时的ASP.NET更改链接按钮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆