简体   繁体   中英

Changing HTML element's style property from code behind

I have a HTML page which is dynamically generating by server. The application has an IDE to generate and design pages then deploy the server. The server displaying this pages in an iframe. We can use all c# methods as well as Page_Load and Page_PreRender events in pages. But I can't modify source code of the asp.net page (I mean can't add 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.

<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. Best way to do it is to inject the jquery script from code behind to do the same work.

Please take a look at this answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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