简体   繁体   English

如何在aspx页面中动态更改样式

[英]how to Change style dynamically in aspx page

How to write below code with <%=%> sign . 如何使用<%=%>符号编写以下代码。 Here Background color is coming from service and I have to put this in server variable like below code . 在这里,背景色来自服务,我必须将其放在服务器变量中,如下面的代码所示。 But its giving warning and not working properly . 但是它发出警告并且无法正常工作。 Please help 请帮忙

style="background-color:<%=servicecall.color%>"

You have to make the service call, before the page is rendered in the asp.net view engine and server send it back to the client. 您必须先进行服务调用,然后页面才能在asp.net视图引擎中呈现,然后服务器将其发送回客户端。 That being said, I would make the call in my serve side code, I would store the result in a variable of the corresponding page class and I would bind this value to the background-color, like 话虽如此,我将在我的服务端代码中进行调用,将结果存储在相应页面类的变量中,并将该值绑定到background-color,例如

 style="background-color:<%=color%>"

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

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