简体   繁体   English

更改按钮上的ASP.NET项目的CSS类单击后面的代码

[英]Changing CSS class of ASP.NET items on button click in code behind

I am having trouble changing the css of ASP.NET items on click of buttons. 单击按钮时,我无法更改ASP.NET项目的CSS。

I know I am able to do this; 我知道我能够做到;

ASPxButton2.Attributes("class") = "Block-Button Button-Blue"

However you can't send objects through CommandArguments (as far as I know). 但是,据我所知,您不能通过CommandArguments发送对象。

And you don't have an Attributes method on FindControl. 而且您在FindControl上没有Attributes方法。

My question is, how can I send/get 3 separate lists of object on a OnClick event in codebehind to change their css class? 我的问题是,如何在代码隐藏的OnClick事件上发送/获取3个单独的对象列表以更改其CSS类? Alternatively is there a way to get the item by it's ID as a string like GetElementById("ElementID") 另外,还有一种方法可以通过其ID像GetElementById(“ ElementID”)这样的字符串来获取项目

You can assign commandargument for the button, or assign string or serialised json in hidden field on client side. 您可以为按钮分配命令参数,或在客户端的隐藏字段中分配字符串或序列化的json。

In both cases you will be able to access values on server side. 在这两种情况下,您都可以在服务器端访问值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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