Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So you could use a css id selector this way.</p> <pre><code>#layoutsectiondiv { color: red } </code></pre> <p>with the following html</p> <pre><code>&lt;div id="layoutsectiondiv"&gt; &lt;/div&gt; </code></pre> <p>Or a css class html selector like this.</p> <pre><code>.layoutsectiondiv { color: blue } </code></pre> <p>with the following html</p> <pre><code>&lt;div class="layoutsectiondiv"&gt; &lt;/div&gt; </code></pre> <p>If you want to control the style of a particular .net control, ie one that has the runat="server" attribute, then as we know .net will 'mangle' the id to ensure its unique.</p> <p>In this case in our code we can use FindControl to access the div and change its style</p> <pre><code>&lt;div id="testDiv" runat="server"&gt; &lt;/div&gt; </code></pre> <p>ie.</p> <pre><code> HtmlGenericControl testDiv = (HtmlGenericControl)Page.FindControl("testDiv"); // to hide testDiv.Attributes.Add("style", "display: none"); // OR testDiv.Attributes["style"] = "display: none"; // to show testDiv.Attributes.Add("style", "display: block"); // OR testDiv.Attributes["style"] = "display: block"; // or to add a class testDiv.Attributes.Add("class", "MyCssClassName"); // OR testDiv.Attributes["class"] = "MyCssClassName"; </code></pre> <p>Here is a good explanation on the difference between css id and class - <a href="https://stackoverflow.com/questions/544010/css-div-id-vs-div-class">CSS: div id VS. div class</a>.</p> <p>And here for <a href="https://stackoverflow.com/questions/175381/how-to-edit-css-style-of-a-div-using-c-in-net">How to edit CSS style of a div using C# in .NET</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload