简体   繁体   English

从后面的代码更改HTML元素的样式属性

[英]Changing HTML element's style property from code behind

I have a HTML page which is dynamically generating by server. 我有一个HTML页面,它由服务器动态生成。 The application has an IDE to generate and design pages then deploy the server. 该应用程序有一个IDE来生成和设计页面,然后部署服务器。 The server displaying this pages in an iframe. 服务器在iframe中显示此页面。 We can use all c# methods as well as Page_Load and Page_PreRender events in pages. 我们可以在页面中使用所有c#方法以及Page_Load和Page_PreRender事件。 But I can't modify source code of the asp.net page (I mean can't add runat="server"). 但我无法修改asp.net页面的源代码(我的意思是不能添加runat =“server”)。

What I want to do, finding a html tag by css class ( #form1 > span ) before pre-render then add a new css property in code behind. 我想做什么,在预渲染之前通过css类( #form1 > span )找到一个html标签然后在代码后面添加一个新的css属性。

<form id="form1" action="DocumentViewer.aspx" method="post" autocomplete="off">
   <span>
      <table>
         <tr>
            <td></td>
         </tr>
      </table>
   </span>

Without runat="server" you cannot access the control in code behind. 如果没有runat="server" ,则无法访问后面的代码中的控件。 Best way to do it is to inject the jquery script from code behind to do the same work. 最好的方法是从代码中注入jquery脚本来完成同样的工作。

Please take a look at this answer . 请看一下这个答案

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

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