Get contents of HTML style tag in ASP.NET using C#

HomeC#

Get contents of HTML style tag in ASP.NET using C#

Null propagation operator in C#
Switch operator in C#
Calling a C function from C#

There could be sometimes the need to get the contents of the html style tag, this is a straightforward solution.

The first part is to make the tag be executed at the server side in the aspx page


style runat="server" id="idofthestyle" type="text/css">
    .answerTable thead {
        font-weight: bold;
    }

Then in C# you just have to extract the contents of the tag and add back


string styles = String.Format("
<style type='text/css'>{0}</style>

“, idofthestyle.InnerText);

COMMENTS

DISQUS: 0